@naylence/runtime 0.3.5-test.931 → 0.3.5-test.934
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/dist/browser/index.cjs +1896 -1767
- package/dist/browser/index.mjs +1896 -1767
- package/dist/cjs/naylence/fame/connector/base-async-connector.js +50 -0
- package/dist/cjs/naylence/fame/connector/broadcast-channel-connector.browser.js +65 -1
- package/dist/cjs/naylence/fame/node/upstream-session-manager.js +16 -1
- package/dist/cjs/naylence/fame/telemetry/trace-emitter-factory.js +4 -37
- package/dist/cjs/version.js +2 -2
- package/dist/esm/naylence/fame/connector/base-async-connector.js +50 -0
- package/dist/esm/naylence/fame/connector/broadcast-channel-connector.browser.js +65 -1
- package/dist/esm/naylence/fame/node/upstream-session-manager.js +16 -1
- package/dist/esm/naylence/fame/telemetry/trace-emitter-factory.js +4 -4
- package/dist/esm/version.js +2 -2
- package/dist/node/index.cjs +1955 -1826
- package/dist/node/index.mjs +1955 -1826
- package/dist/node/node.cjs +1620 -1491
- package/dist/node/node.mjs +1620 -1491
- package/dist/types/naylence/fame/connector/broadcast-channel-connector.browser.d.ts +2 -0
- package/dist/types/version.d.ts +1 -1
- package/package.json +1 -1
package/dist/node/node.cjs
CHANGED
|
@@ -2116,6 +2116,10 @@ class BaseAsyncConnector extends TaskSpawner {
|
|
|
2116
2116
|
* Stop the connector gracefully
|
|
2117
2117
|
*/
|
|
2118
2118
|
async stop() {
|
|
2119
|
+
logger$1f.debug('stopping_connector', {
|
|
2120
|
+
current_state: this._state,
|
|
2121
|
+
connector_id: this._connectorFlowId,
|
|
2122
|
+
});
|
|
2119
2123
|
if (!core.ConnectorStateUtils.canStop(this._state)) {
|
|
2120
2124
|
logger$1f.debug('connector_stop_already_stopped', {
|
|
2121
2125
|
current_state: this._state,
|
|
@@ -2128,6 +2132,10 @@ class BaseAsyncConnector extends TaskSpawner {
|
|
|
2128
2132
|
if (this._lastError) {
|
|
2129
2133
|
throw this._lastError;
|
|
2130
2134
|
}
|
|
2135
|
+
logger$1f.debug('connector_stopped', {
|
|
2136
|
+
current_state: this._state,
|
|
2137
|
+
connector_id: this._connectorFlowId,
|
|
2138
|
+
});
|
|
2131
2139
|
}
|
|
2132
2140
|
/**
|
|
2133
2141
|
* Close the connector with optional code and reason
|
|
@@ -2458,8 +2466,21 @@ class BaseAsyncConnector extends TaskSpawner {
|
|
|
2458
2466
|
*/
|
|
2459
2467
|
async _shutdown(code, reason, gracePeriod, exc) {
|
|
2460
2468
|
if (this._closed) {
|
|
2469
|
+
logger$1f.debug('shutdown_already_closed', {
|
|
2470
|
+
connector_id: this._connectorFlowId,
|
|
2471
|
+
current_state: this._state,
|
|
2472
|
+
});
|
|
2461
2473
|
return;
|
|
2462
2474
|
}
|
|
2475
|
+
logger$1f.info('connector_shutdown_starting', {
|
|
2476
|
+
connector_id: this._connectorFlowId,
|
|
2477
|
+
connector_type: this.constructor.name,
|
|
2478
|
+
code,
|
|
2479
|
+
reason,
|
|
2480
|
+
current_state: this._state,
|
|
2481
|
+
has_error: !!exc,
|
|
2482
|
+
timestamp: new Date().toISOString(),
|
|
2483
|
+
});
|
|
2463
2484
|
this._closed = true;
|
|
2464
2485
|
this._closeCode = code;
|
|
2465
2486
|
this._closeReason = reason;
|
|
@@ -2481,16 +2502,39 @@ class BaseAsyncConnector extends TaskSpawner {
|
|
|
2481
2502
|
this._sendPromiseResolve = undefined;
|
|
2482
2503
|
}
|
|
2483
2504
|
// Close transport
|
|
2505
|
+
logger$1f.info('connector_closing_transport', {
|
|
2506
|
+
connector_id: this._connectorFlowId,
|
|
2507
|
+
connector_type: this.constructor.name,
|
|
2508
|
+
timestamp: new Date().toISOString(),
|
|
2509
|
+
});
|
|
2484
2510
|
await this._transportClose(code, reason);
|
|
2511
|
+
logger$1f.info('connector_transport_closed', {
|
|
2512
|
+
connector_id: this._connectorFlowId,
|
|
2513
|
+
connector_type: this.constructor.name,
|
|
2514
|
+
timestamp: new Date().toISOString(),
|
|
2515
|
+
});
|
|
2485
2516
|
// Shutdown spawned tasks
|
|
2517
|
+
logger$1f.info('connector_shutting_down_tasks', {
|
|
2518
|
+
connector_id: this._connectorFlowId,
|
|
2519
|
+
connector_type: this.constructor.name,
|
|
2520
|
+
grace_period_ms: effectiveGracePeriod * 1000,
|
|
2521
|
+
join_timeout_ms: this._shutdownJoinTimeout,
|
|
2522
|
+
timestamp: new Date().toISOString(),
|
|
2523
|
+
});
|
|
2486
2524
|
try {
|
|
2487
2525
|
await this.shutdownTasks({
|
|
2488
2526
|
gracePeriod: effectiveGracePeriod * 1000, // Convert to milliseconds
|
|
2489
2527
|
joinTimeout: this._shutdownJoinTimeout,
|
|
2490
2528
|
});
|
|
2529
|
+
logger$1f.info('connector_tasks_shutdown_complete', {
|
|
2530
|
+
connector_id: this._connectorFlowId,
|
|
2531
|
+
connector_type: this.constructor.name,
|
|
2532
|
+
timestamp: new Date().toISOString(),
|
|
2533
|
+
});
|
|
2491
2534
|
}
|
|
2492
2535
|
catch (error) {
|
|
2493
2536
|
logger$1f.warning('task_shutdown_error', {
|
|
2537
|
+
connector_id: this._connectorFlowId,
|
|
2494
2538
|
error: error instanceof Error ? error.message : String(error),
|
|
2495
2539
|
});
|
|
2496
2540
|
}
|
|
@@ -2502,6 +2546,12 @@ class BaseAsyncConnector extends TaskSpawner {
|
|
|
2502
2546
|
if (this._closeResolver) {
|
|
2503
2547
|
this._closeResolver();
|
|
2504
2548
|
}
|
|
2549
|
+
logger$1f.info('connector_shutdown_complete', {
|
|
2550
|
+
connector_id: this._connectorFlowId,
|
|
2551
|
+
connector_type: this.constructor.name,
|
|
2552
|
+
final_state: this._state,
|
|
2553
|
+
timestamp: new Date().toISOString(),
|
|
2554
|
+
});
|
|
2505
2555
|
}
|
|
2506
2556
|
/**
|
|
2507
2557
|
* Close the underlying transport
|
|
@@ -5386,12 +5436,12 @@ for (const [name, config] of Object.entries(SQLITE_PROFILES)) {
|
|
|
5386
5436
|
}
|
|
5387
5437
|
|
|
5388
5438
|
// This file is auto-generated during build - do not edit manually
|
|
5389
|
-
// Generated from package.json version: 0.3.5-test.
|
|
5439
|
+
// Generated from package.json version: 0.3.5-test.934
|
|
5390
5440
|
/**
|
|
5391
5441
|
* The package version, injected at build time.
|
|
5392
5442
|
* @internal
|
|
5393
5443
|
*/
|
|
5394
|
-
const VERSION = '0.3.5-test.
|
|
5444
|
+
const VERSION = '0.3.5-test.934';
|
|
5395
5445
|
|
|
5396
5446
|
/**
|
|
5397
5447
|
* Fame errors module - Fame protocol specific error classes
|
|
@@ -11431,6 +11481,7 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
11431
11481
|
this.ackDedupTtlMs = 30000;
|
|
11432
11482
|
this.ackDedupMaxEntries = 4096;
|
|
11433
11483
|
this.textDecoder = new TextDecoder();
|
|
11484
|
+
this.visibilityChangeListenerRegistered = false;
|
|
11434
11485
|
this.channelName =
|
|
11435
11486
|
typeof config.channelName === 'string' && config.channelName.trim().length > 0
|
|
11436
11487
|
? config.channelName.trim()
|
|
@@ -11443,12 +11494,22 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
11443
11494
|
this.inbox = new BoundedAsyncQueue(preferredCapacity);
|
|
11444
11495
|
this.connectorId = BroadcastChannelConnector.generateConnectorId();
|
|
11445
11496
|
this.channel = new BroadcastChannel(this.channelName);
|
|
11446
|
-
logger$10.
|
|
11497
|
+
logger$10.info('broadcast_channel_connector_created', {
|
|
11447
11498
|
channel: this.channelName,
|
|
11448
11499
|
connector_id: this.connectorId,
|
|
11449
11500
|
inbox_capacity: preferredCapacity,
|
|
11501
|
+
timestamp: new Date().toISOString(),
|
|
11450
11502
|
});
|
|
11451
11503
|
this.onMsg = (event) => {
|
|
11504
|
+
// Guard: Don't process if listener was unregistered
|
|
11505
|
+
if (!this.listenerRegistered) {
|
|
11506
|
+
logger$10.warning('broadcast_channel_message_after_unregister', {
|
|
11507
|
+
channel: this.channelName,
|
|
11508
|
+
connector_id: this.connectorId,
|
|
11509
|
+
timestamp: new Date().toISOString(),
|
|
11510
|
+
});
|
|
11511
|
+
return;
|
|
11512
|
+
}
|
|
11452
11513
|
const message = event.data;
|
|
11453
11514
|
logger$10.debug('broadcast_channel_raw_event', {
|
|
11454
11515
|
channel: this.channelName,
|
|
@@ -11511,6 +11572,26 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
11511
11572
|
};
|
|
11512
11573
|
this.channel.addEventListener('message', this.onMsg);
|
|
11513
11574
|
this.listenerRegistered = true;
|
|
11575
|
+
// Setup visibility change monitoring
|
|
11576
|
+
this.visibilityChangeHandler = () => {
|
|
11577
|
+
const isHidden = document.hidden;
|
|
11578
|
+
logger$10.info('broadcast_channel_visibility_changed', {
|
|
11579
|
+
channel: this.channelName,
|
|
11580
|
+
connector_id: this.connectorId,
|
|
11581
|
+
visibility: isHidden ? 'hidden' : 'visible',
|
|
11582
|
+
timestamp: new Date().toISOString(),
|
|
11583
|
+
});
|
|
11584
|
+
};
|
|
11585
|
+
if (typeof document !== 'undefined') {
|
|
11586
|
+
document.addEventListener('visibilitychange', this.visibilityChangeHandler);
|
|
11587
|
+
this.visibilityChangeListenerRegistered = true;
|
|
11588
|
+
// Log initial state
|
|
11589
|
+
logger$10.info('broadcast_channel_initial_visibility', {
|
|
11590
|
+
channel: this.channelName,
|
|
11591
|
+
connector_id: this.connectorId,
|
|
11592
|
+
visibility: document.hidden ? 'hidden' : 'visible',
|
|
11593
|
+
});
|
|
11594
|
+
}
|
|
11514
11595
|
}
|
|
11515
11596
|
async pushToReceive(rawOrEnvelope) {
|
|
11516
11597
|
const item = this._normalizeInboxItem(rawOrEnvelope);
|
|
@@ -11555,11 +11636,44 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
11555
11636
|
return await this.inbox.dequeue();
|
|
11556
11637
|
}
|
|
11557
11638
|
async _transportClose(code, reason) {
|
|
11639
|
+
logger$10.info('broadcast_channel_transport_closing', {
|
|
11640
|
+
channel: this.channelName,
|
|
11641
|
+
connector_id: this.connectorId,
|
|
11642
|
+
code,
|
|
11643
|
+
reason,
|
|
11644
|
+
listener_registered: this.listenerRegistered,
|
|
11645
|
+
timestamp: new Date().toISOString(),
|
|
11646
|
+
});
|
|
11558
11647
|
if (this.listenerRegistered) {
|
|
11648
|
+
logger$10.info('broadcast_channel_removing_listener', {
|
|
11649
|
+
channel: this.channelName,
|
|
11650
|
+
connector_id: this.connectorId,
|
|
11651
|
+
timestamp: new Date().toISOString(),
|
|
11652
|
+
});
|
|
11559
11653
|
this.channel.removeEventListener('message', this.onMsg);
|
|
11560
11654
|
this.listenerRegistered = false;
|
|
11655
|
+
logger$10.info('broadcast_channel_listener_removed', {
|
|
11656
|
+
channel: this.channelName,
|
|
11657
|
+
connector_id: this.connectorId,
|
|
11658
|
+
timestamp: new Date().toISOString(),
|
|
11659
|
+
});
|
|
11660
|
+
}
|
|
11661
|
+
if (this.visibilityChangeListenerRegistered && this.visibilityChangeHandler && typeof document !== 'undefined') {
|
|
11662
|
+
document.removeEventListener('visibilitychange', this.visibilityChangeHandler);
|
|
11663
|
+
this.visibilityChangeListenerRegistered = false;
|
|
11664
|
+
this.visibilityChangeHandler = undefined;
|
|
11561
11665
|
}
|
|
11666
|
+
logger$10.info('broadcast_channel_closing', {
|
|
11667
|
+
channel: this.channelName,
|
|
11668
|
+
connector_id: this.connectorId,
|
|
11669
|
+
timestamp: new Date().toISOString(),
|
|
11670
|
+
});
|
|
11562
11671
|
this.channel.close();
|
|
11672
|
+
logger$10.info('broadcast_channel_closed', {
|
|
11673
|
+
channel: this.channelName,
|
|
11674
|
+
connector_id: this.connectorId,
|
|
11675
|
+
timestamp: new Date().toISOString(),
|
|
11676
|
+
});
|
|
11563
11677
|
const closeCode = typeof code === 'number' ? code : 1000;
|
|
11564
11678
|
const closeReason = typeof reason === 'string' && reason.length > 0 ? reason : 'closed';
|
|
11565
11679
|
const shutdownError = new FameTransportClose(closeReason, closeCode);
|
|
@@ -12162,7 +12276,22 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
12162
12276
|
this.currentStopSubtasks = null;
|
|
12163
12277
|
await Promise.allSettled(tasks.map((task) => task.promise));
|
|
12164
12278
|
if (this.connector) {
|
|
12165
|
-
|
|
12279
|
+
logger$$.info('upstream_stopping_old_connector', {
|
|
12280
|
+
connect_epoch: this.connectEpoch,
|
|
12281
|
+
target_system_id: this.targetSystemId,
|
|
12282
|
+
timestamp: new Date().toISOString(),
|
|
12283
|
+
});
|
|
12284
|
+
await this.connector.stop().catch((err) => {
|
|
12285
|
+
logger$$.warning('upstream_connector_stop_error', {
|
|
12286
|
+
connect_epoch: this.connectEpoch,
|
|
12287
|
+
error: err instanceof Error ? err.message : String(err),
|
|
12288
|
+
});
|
|
12289
|
+
});
|
|
12290
|
+
logger$$.info('upstream_old_connector_stopped', {
|
|
12291
|
+
connect_epoch: this.connectEpoch,
|
|
12292
|
+
target_system_id: this.targetSystemId,
|
|
12293
|
+
timestamp: new Date().toISOString(),
|
|
12294
|
+
});
|
|
12166
12295
|
this.connector = null;
|
|
12167
12296
|
}
|
|
12168
12297
|
}
|
|
@@ -14176,10 +14305,10 @@ class TraceEmitterFactory extends factory.AbstractResourceFactory {
|
|
|
14176
14305
|
return traceEmitter;
|
|
14177
14306
|
}
|
|
14178
14307
|
}
|
|
14179
|
-
// Ensure default factories are registered lazily to avoid circular ESM initialization issues
|
|
14180
|
-
void
|
|
14181
|
-
void
|
|
14182
|
-
void
|
|
14308
|
+
// // Ensure default factories are registered lazily to avoid circular ESM initialization issues
|
|
14309
|
+
// void import('./noop-trace-emitter-factory.js');
|
|
14310
|
+
// void import('./open-telemetry-trace-emitter-factory.js');
|
|
14311
|
+
// void import('./trace-emitter-profile-factory.js');
|
|
14183
14312
|
|
|
14184
14313
|
const BINDING_STORE_NAMESPACE = '__binding_store';
|
|
14185
14314
|
const logger$X = getLogger('naylence.fame.node.factory_commons');
|
|
@@ -34181,839 +34310,217 @@ async function main() {
|
|
|
34181
34310
|
process.on('SIGTERM', () => shutdown('SIGTERM'));
|
|
34182
34311
|
}
|
|
34183
34312
|
|
|
34184
|
-
|
|
34185
|
-
|
|
34186
|
-
|
|
34187
|
-
|
|
34188
|
-
|
|
34189
|
-
|
|
34190
|
-
|
|
34191
|
-
}
|
|
34192
|
-
|
|
34193
|
-
|
|
34194
|
-
|
|
34195
|
-
|
|
34196
|
-
|
|
34197
|
-
|
|
34198
|
-
|
|
34199
|
-
|
|
34200
|
-
|
|
34201
|
-
|
|
34202
|
-
|
|
34203
|
-
|
|
34204
|
-
'env.frame_type': envelope.frame
|
|
34205
|
-
? (envelope.frame.type ?? null)
|
|
34206
|
-
: null,
|
|
34207
|
-
'env.is_signed': Boolean(envelope.sec?.sig),
|
|
34208
|
-
'env.sign_kid': envelope.sec?.sig?.kid ?? null,
|
|
34209
|
-
'env.is_encrypted': Boolean(envelope.sec?.enc),
|
|
34210
|
-
'env.enc_kid': envelope.sec?.enc?.kid ?? null,
|
|
34211
|
-
};
|
|
34313
|
+
/**
|
|
34314
|
+
* Base abstraction for message delivery policies.
|
|
34315
|
+
*/
|
|
34316
|
+
class DeliveryPolicy {
|
|
34317
|
+
constructor(options = {}) {
|
|
34318
|
+
this.senderPolicy = options.senderRetryPolicy;
|
|
34319
|
+
this.receiverPolicy = options.receiverRetryPolicy;
|
|
34320
|
+
}
|
|
34321
|
+
/**
|
|
34322
|
+
* Determine if the policy requires an acknowledgement for the envelope.
|
|
34323
|
+
*/
|
|
34324
|
+
isAckRequired(_envelope) {
|
|
34325
|
+
return false;
|
|
34326
|
+
}
|
|
34327
|
+
get senderRetryPolicy() {
|
|
34328
|
+
return this.senderPolicy;
|
|
34329
|
+
}
|
|
34330
|
+
get receiverRetryPolicy() {
|
|
34331
|
+
return this.receiverPolicy;
|
|
34332
|
+
}
|
|
34212
34333
|
}
|
|
34213
|
-
|
|
34214
|
-
|
|
34215
|
-
|
|
34216
|
-
|
|
34217
|
-
|
|
34334
|
+
|
|
34335
|
+
/**
|
|
34336
|
+
* Message delivery policy that ensures envelopes are delivered at least once.
|
|
34337
|
+
*/
|
|
34338
|
+
class AtLeastOnceDeliveryPolicy extends DeliveryPolicy {
|
|
34339
|
+
constructor(options = {}) {
|
|
34340
|
+
super(options);
|
|
34341
|
+
}
|
|
34342
|
+
isAckRequired(envelope) {
|
|
34343
|
+
const frame = envelope?.frame;
|
|
34344
|
+
const frameType = typeof frame?.type === 'string' ? frame.type : null;
|
|
34345
|
+
if (!frameType) {
|
|
34346
|
+
return false;
|
|
34218
34347
|
}
|
|
34348
|
+
return frameType === 'Data' || frameType === 'DataFrame';
|
|
34219
34349
|
}
|
|
34220
|
-
return filtered;
|
|
34221
34350
|
}
|
|
34222
|
-
|
|
34223
|
-
|
|
34224
|
-
|
|
34351
|
+
|
|
34352
|
+
/**
|
|
34353
|
+
* Configuration and helper for retry backoff behaviour.
|
|
34354
|
+
*/
|
|
34355
|
+
class RetryPolicy {
|
|
34356
|
+
constructor(options = {}) {
|
|
34357
|
+
this.maxRetries = Math.max(0, Math.trunc(options.maxRetries ?? 0));
|
|
34358
|
+
this.baseDelayMs = Math.max(0, Math.trunc(options.baseDelayMs ?? 200));
|
|
34359
|
+
this.maxDelayMs = Math.max(this.baseDelayMs, Math.trunc(options.maxDelayMs ?? 10000));
|
|
34360
|
+
this.jitterMs = Math.max(0, Math.trunc(options.jitterMs ?? 50));
|
|
34361
|
+
this.backoffFactor = Math.max(0, options.backoffFactor ?? 2.0);
|
|
34225
34362
|
}
|
|
34226
|
-
|
|
34227
|
-
|
|
34228
|
-
|
|
34229
|
-
|
|
34230
|
-
|
|
34231
|
-
|
|
34232
|
-
|
|
34233
|
-
|
|
34363
|
+
/**
|
|
34364
|
+
* Calculate the next retry delay based on attempt number (0-indexed).
|
|
34365
|
+
*/
|
|
34366
|
+
nextDelayMs(attempt) {
|
|
34367
|
+
const normalizedAttempt = Number.isFinite(attempt)
|
|
34368
|
+
? Math.max(0, Math.trunc(attempt))
|
|
34369
|
+
: 0;
|
|
34370
|
+
const base = normalizedAttempt <= 0
|
|
34371
|
+
? this.baseDelayMs
|
|
34372
|
+
: Math.round(this.baseDelayMs * this.backoffFactor ** normalizedAttempt);
|
|
34373
|
+
const jitter = this.jitterMs > 0
|
|
34374
|
+
? Math.round((Math.random() * 2 - 1) * this.jitterMs)
|
|
34375
|
+
: 0;
|
|
34376
|
+
const withJitter = base + jitter;
|
|
34377
|
+
return Math.min(this.maxDelayMs, Math.max(0, withJitter));
|
|
34234
34378
|
}
|
|
34235
|
-
return undefined;
|
|
34236
34379
|
}
|
|
34237
|
-
|
|
34380
|
+
|
|
34381
|
+
const LEGACY_POLICY_KEYS = {
|
|
34382
|
+
senderRetryPolicy: ['sender_retry_policy', 'sender_retryPolicy'],
|
|
34383
|
+
receiverRetryPolicy: ['receiver_retry_policy', 'receiver_retryPolicy'],
|
|
34384
|
+
};
|
|
34385
|
+
class AtLeastOnceDeliveryPolicyFactory extends DeliveryPolicyFactory {
|
|
34238
34386
|
constructor() {
|
|
34239
34387
|
super(...arguments);
|
|
34240
|
-
this.
|
|
34241
|
-
this.
|
|
34242
|
-
this.priority = 10000;
|
|
34388
|
+
this.type = 'AtLeastOnceDeliveryPolicy';
|
|
34389
|
+
this.isDefault = true;
|
|
34243
34390
|
}
|
|
34244
|
-
|
|
34245
|
-
|
|
34391
|
+
async create(config) {
|
|
34392
|
+
const normalized = normalizeAtLeastOnceConfig(config);
|
|
34393
|
+
const options = {
|
|
34394
|
+
...(normalized.senderRetryPolicy
|
|
34395
|
+
? { senderRetryPolicy: normalized.senderRetryPolicy }
|
|
34396
|
+
: {}),
|
|
34397
|
+
...(normalized.receiverRetryPolicy
|
|
34398
|
+
? { receiverRetryPolicy: normalized.receiverRetryPolicy }
|
|
34399
|
+
: {}),
|
|
34400
|
+
};
|
|
34401
|
+
return new AtLeastOnceDeliveryPolicy(options);
|
|
34246
34402
|
}
|
|
34247
|
-
|
|
34248
|
-
|
|
34249
|
-
|
|
34250
|
-
|
|
34251
|
-
if (previous) {
|
|
34252
|
-
this.inflight.delete(key);
|
|
34253
|
-
try {
|
|
34254
|
-
previous.scope.exit();
|
|
34255
|
-
}
|
|
34256
|
-
catch (cleanupError) {
|
|
34257
|
-
logTelemetryFailure('trace_span_scope_exit_failed', cleanupError, {
|
|
34258
|
-
operation: operationName,
|
|
34259
|
-
span_key: key,
|
|
34260
|
-
});
|
|
34261
|
-
}
|
|
34262
|
-
}
|
|
34263
|
-
const attributes = buildEnvelopeAttributes(envelope);
|
|
34264
|
-
if (additionalAttributes) {
|
|
34265
|
-
for (const [attrKey, attrValue] of Object.entries(additionalAttributes)) {
|
|
34266
|
-
attributes[attrKey] = attrValue;
|
|
34267
|
-
}
|
|
34268
|
-
}
|
|
34269
|
-
const effectiveNode = node ?? this.node;
|
|
34270
|
-
if (effectiveNode) {
|
|
34271
|
-
attributes['node.id'] = effectiveNode.id;
|
|
34272
|
-
attributes['node.sid'] = effectiveNode.sid ?? null;
|
|
34273
|
-
}
|
|
34274
|
-
const scope = this.startSpan(operationName, {
|
|
34275
|
-
attributes: filterAttributes(attributes),
|
|
34276
|
-
});
|
|
34277
|
-
const span = scope.enter();
|
|
34278
|
-
this.inflight.set(key, { scope, span });
|
|
34279
|
-
}
|
|
34280
|
-
catch (error) {
|
|
34281
|
-
logTelemetryFailure('trace_span_start_failed', error, {
|
|
34282
|
-
operation: operationName,
|
|
34283
|
-
envelope_id: envelope.id,
|
|
34284
|
-
});
|
|
34285
|
-
}
|
|
34286
|
-
return envelope;
|
|
34403
|
+
}
|
|
34404
|
+
function normalizeAtLeastOnceConfig(config) {
|
|
34405
|
+
if (!config) {
|
|
34406
|
+
return {};
|
|
34287
34407
|
}
|
|
34288
|
-
|
|
34289
|
-
|
|
34290
|
-
|
|
34291
|
-
|
|
34292
|
-
|
|
34293
|
-
|
|
34294
|
-
|
|
34295
|
-
|
|
34296
|
-
|
|
34297
|
-
|
|
34298
|
-
|
|
34299
|
-
|
|
34300
|
-
|
|
34301
|
-
attributes['node.id'] = effectiveNode.id;
|
|
34302
|
-
attributes['node.sid'] = effectiveNode.sid ?? null;
|
|
34303
|
-
}
|
|
34304
|
-
const scope = this.startSpan(operationName, {
|
|
34305
|
-
attributes: filterAttributes(attributes),
|
|
34306
|
-
});
|
|
34307
|
-
const span = scope.enter();
|
|
34308
|
-
active = { scope, span };
|
|
34309
|
-
}
|
|
34310
|
-
else {
|
|
34311
|
-
this.inflight.delete(key);
|
|
34312
|
-
}
|
|
34313
|
-
if (error !== null && error !== undefined) {
|
|
34314
|
-
try {
|
|
34315
|
-
active.span.recordException(error);
|
|
34316
|
-
}
|
|
34317
|
-
catch (recordError) {
|
|
34318
|
-
logTelemetryFailure('trace_span_record_exception_failed', recordError, {
|
|
34319
|
-
operation: operationName,
|
|
34320
|
-
envelope_id: envelope.id,
|
|
34321
|
-
});
|
|
34322
|
-
}
|
|
34323
|
-
try {
|
|
34324
|
-
const description = error instanceof Error ? error.message : String(error);
|
|
34325
|
-
active.span.setStatusError(description);
|
|
34326
|
-
}
|
|
34327
|
-
catch (statusError) {
|
|
34328
|
-
logTelemetryFailure('trace_span_set_status_failed', statusError, {
|
|
34329
|
-
operation: operationName,
|
|
34330
|
-
envelope_id: envelope.id,
|
|
34331
|
-
});
|
|
34332
|
-
}
|
|
34333
|
-
}
|
|
34334
|
-
try {
|
|
34335
|
-
active.scope.exit();
|
|
34336
|
-
}
|
|
34337
|
-
catch (exitError) {
|
|
34338
|
-
logTelemetryFailure('trace_span_scope_exit_failed', exitError, {
|
|
34339
|
-
operation: operationName,
|
|
34340
|
-
envelope_id: envelope.id,
|
|
34341
|
-
});
|
|
34342
|
-
}
|
|
34343
|
-
}
|
|
34344
|
-
catch (error) {
|
|
34345
|
-
logTelemetryFailure('trace_span_complete_failed', error, {
|
|
34346
|
-
operation: operationName,
|
|
34347
|
-
envelope_id: envelope.id,
|
|
34348
|
-
});
|
|
34349
|
-
}
|
|
34350
|
-
return envelope;
|
|
34408
|
+
const candidate = config;
|
|
34409
|
+
const senderPolicyInput = getRetryPolicyInput(candidate, 'senderRetryPolicy');
|
|
34410
|
+
const receiverPolicyInput = getRetryPolicyInput(candidate, 'receiverRetryPolicy');
|
|
34411
|
+
return {
|
|
34412
|
+
senderRetryPolicy: resolveRetryPolicy(senderPolicyInput),
|
|
34413
|
+
receiverRetryPolicy: resolveRetryPolicy(receiverPolicyInput),
|
|
34414
|
+
};
|
|
34415
|
+
}
|
|
34416
|
+
function getRetryPolicyInput(candidate, key) {
|
|
34417
|
+
const camelKey = key;
|
|
34418
|
+
const primary = candidate[camelKey];
|
|
34419
|
+
if (primary !== undefined) {
|
|
34420
|
+
return primary;
|
|
34351
34421
|
}
|
|
34352
|
-
|
|
34353
|
-
|
|
34354
|
-
|
|
34355
|
-
|
|
34356
|
-
|
|
34357
|
-
|
|
34358
|
-
'fromSystemId',
|
|
34359
|
-
'from_system_id',
|
|
34360
|
-
'fromNodeId',
|
|
34361
|
-
'from_node_id',
|
|
34362
|
-
]);
|
|
34363
|
-
if (fromNodeId !== undefined && fromNodeId !== null) {
|
|
34364
|
-
attributes['from.node_id'] = String(fromNodeId);
|
|
34365
|
-
}
|
|
34366
|
-
const originType = extractContextValue(context, [
|
|
34367
|
-
'originType',
|
|
34368
|
-
'origin_type',
|
|
34369
|
-
]);
|
|
34370
|
-
if (originType !== undefined && originType !== null) {
|
|
34371
|
-
attributes['from.origin_type'] = String(originType);
|
|
34372
|
-
}
|
|
34373
|
-
const scope = this.startSpan('env.received', {
|
|
34374
|
-
attributes: filterAttributes(attributes),
|
|
34375
|
-
});
|
|
34376
|
-
scope.enter();
|
|
34377
|
-
scope.exit();
|
|
34378
|
-
}
|
|
34379
|
-
catch (error) {
|
|
34380
|
-
logTelemetryFailure('trace_span_received_failed', error, {
|
|
34381
|
-
envelope_id: envelope.id,
|
|
34382
|
-
});
|
|
34422
|
+
const legacyKeys = LEGACY_POLICY_KEYS[key] ?? [];
|
|
34423
|
+
for (const legacyKey of legacyKeys) {
|
|
34424
|
+
const value = candidate[legacyKey];
|
|
34425
|
+
if (value !== undefined) {
|
|
34426
|
+
candidate[camelKey] = value;
|
|
34427
|
+
return value;
|
|
34383
34428
|
}
|
|
34384
|
-
return envelope;
|
|
34385
|
-
}
|
|
34386
|
-
async onForwardToRoute(node, nextSegment, envelope, _context) {
|
|
34387
|
-
return this.startEnvelopeOperationSpan(node, 'env.fwd_to_route', envelope, nextSegment, {
|
|
34388
|
-
'route.segment': nextSegment,
|
|
34389
|
-
});
|
|
34390
|
-
}
|
|
34391
|
-
async onForwardToRouteComplete(node, nextSegment, envelope, result, error, _context) {
|
|
34392
|
-
return this.completeEnvelopeOperationSpan(node, 'env.fwd_to_route', envelope, nextSegment, result, error, {
|
|
34393
|
-
'route.segment': nextSegment,
|
|
34394
|
-
});
|
|
34395
|
-
}
|
|
34396
|
-
async onForwardUpstream(node, envelope, _context) {
|
|
34397
|
-
return this.startEnvelopeOperationSpan(node, 'env.fwd_upstream', envelope, 'upstream', {
|
|
34398
|
-
direction: 'upstream',
|
|
34399
|
-
});
|
|
34400
34429
|
}
|
|
34401
|
-
|
|
34402
|
-
|
|
34403
|
-
|
|
34404
|
-
|
|
34405
|
-
|
|
34406
|
-
async onForwardToPeer(node, peerSegment, envelope, _context) {
|
|
34407
|
-
return this.startEnvelopeOperationSpan(node, 'env.fwd_to_peer', envelope, peerSegment, {
|
|
34408
|
-
'peer.segment': peerSegment,
|
|
34409
|
-
});
|
|
34410
|
-
}
|
|
34411
|
-
async onForwardToPeerComplete(node, peerSegment, envelope, result, error, _context) {
|
|
34412
|
-
return this.completeEnvelopeOperationSpan(node, 'env.fwd_to_peer', envelope, peerSegment, result, error, {
|
|
34413
|
-
'peer.segment': peerSegment,
|
|
34414
|
-
});
|
|
34415
|
-
}
|
|
34416
|
-
async onDeliverLocal(node, address, envelope, _context) {
|
|
34417
|
-
const addressKey = address ? String(address) : 'unknown';
|
|
34418
|
-
return this.startEnvelopeOperationSpan(node, 'env.deliver_local', envelope, addressKey, {
|
|
34419
|
-
'delivery.address': addressKey,
|
|
34420
|
-
'delivery.type': 'local',
|
|
34421
|
-
});
|
|
34422
|
-
}
|
|
34423
|
-
async onDeliverLocalComplete(node, address, envelope, _context) {
|
|
34424
|
-
const addressKey = address ? String(address) : 'unknown';
|
|
34425
|
-
return this.completeEnvelopeOperationSpan(node, 'env.deliver_local', envelope, addressKey, null, null, {
|
|
34426
|
-
'delivery.address': addressKey,
|
|
34427
|
-
'delivery.type': 'local',
|
|
34428
|
-
});
|
|
34430
|
+
return undefined;
|
|
34431
|
+
}
|
|
34432
|
+
function resolveRetryPolicy(input) {
|
|
34433
|
+
if (!input) {
|
|
34434
|
+
return undefined;
|
|
34429
34435
|
}
|
|
34430
|
-
|
|
34431
|
-
|
|
34436
|
+
if (input instanceof RetryPolicy) {
|
|
34437
|
+
return input;
|
|
34432
34438
|
}
|
|
34433
|
-
|
|
34434
|
-
|
|
34435
|
-
|
|
34436
|
-
|
|
34439
|
+
const record = input;
|
|
34440
|
+
const options = {
|
|
34441
|
+
...(withOption(record, ['maxRetries', 'max_retries']) ?? {}),
|
|
34442
|
+
...(withOption(record, ['baseDelayMs', 'base_delay_ms']) ?? {}),
|
|
34443
|
+
...(withOption(record, ['maxDelayMs', 'max_delay_ms']) ?? {}),
|
|
34444
|
+
...(withOption(record, ['jitterMs', 'jitter_ms']) ?? {}),
|
|
34445
|
+
...(withOption(record, ['backoffFactor', 'backoff_factor']) ?? {}),
|
|
34446
|
+
};
|
|
34447
|
+
return new RetryPolicy(options);
|
|
34448
|
+
}
|
|
34449
|
+
function extractNumber(source, keys) {
|
|
34450
|
+
for (const key of keys) {
|
|
34451
|
+
if (key in source) {
|
|
34452
|
+
const value = source[key];
|
|
34453
|
+
if (typeof value === 'number' && Number.isFinite(value)) {
|
|
34454
|
+
return value;
|
|
34437
34455
|
}
|
|
34438
|
-
if (typeof
|
|
34439
|
-
|
|
34456
|
+
if (typeof value === 'string' && value.trim().length > 0) {
|
|
34457
|
+
const parsed = Number(value);
|
|
34458
|
+
if (!Number.isNaN(parsed)) {
|
|
34459
|
+
return parsed;
|
|
34460
|
+
}
|
|
34440
34461
|
}
|
|
34441
34462
|
}
|
|
34442
|
-
catch (error) {
|
|
34443
|
-
logTelemetryFailure('trace_span_shutdown_failed', error);
|
|
34444
|
-
}
|
|
34445
|
-
}
|
|
34446
|
-
async flush() {
|
|
34447
|
-
// Default implementation: no-op
|
|
34448
34463
|
}
|
|
34449
|
-
|
|
34450
|
-
|
|
34464
|
+
return undefined;
|
|
34465
|
+
}
|
|
34466
|
+
function withOption(source, keys) {
|
|
34467
|
+
const value = extractNumber(source, keys);
|
|
34468
|
+
if (value === undefined) {
|
|
34469
|
+
return undefined;
|
|
34451
34470
|
}
|
|
34471
|
+
const camelKey = keys[0];
|
|
34472
|
+
return {
|
|
34473
|
+
[camelKey]: value,
|
|
34474
|
+
};
|
|
34452
34475
|
}
|
|
34476
|
+
const FACTORY_META$R = {
|
|
34477
|
+
base: DELIVERY_POLICY_FACTORY_BASE_TYPE,
|
|
34478
|
+
key: 'AtLeastOnceDeliveryPolicy',
|
|
34479
|
+
};
|
|
34453
34480
|
|
|
34454
|
-
|
|
34455
|
-
|
|
34456
|
-
|
|
34457
|
-
|
|
34458
|
-
|
|
34459
|
-
|
|
34460
|
-
|
|
34461
|
-
|
|
34462
|
-
|
|
34463
|
-
|
|
34464
|
-
|
|
34481
|
+
var atLeastOnceDeliveryPolicyFactory = /*#__PURE__*/Object.freeze({
|
|
34482
|
+
__proto__: null,
|
|
34483
|
+
AtLeastOnceDeliveryPolicyFactory: AtLeastOnceDeliveryPolicyFactory,
|
|
34484
|
+
FACTORY_META: FACTORY_META$R,
|
|
34485
|
+
default: AtLeastOnceDeliveryPolicyFactory
|
|
34486
|
+
});
|
|
34487
|
+
|
|
34488
|
+
/**
|
|
34489
|
+
* Message delivery policy that ensures envelopes are delivered at most once.
|
|
34490
|
+
*/
|
|
34491
|
+
class AtMostOnceDeliveryPolicy extends DeliveryPolicy {
|
|
34492
|
+
constructor() {
|
|
34493
|
+
super();
|
|
34465
34494
|
}
|
|
34466
|
-
|
|
34467
|
-
|
|
34468
|
-
class NoopTraceEmitter extends BaseTraceEmitter {
|
|
34469
|
-
startSpan(_name, _options) {
|
|
34470
|
-
void _options;
|
|
34471
|
-
return new NoopTraceSpanScope(new NoopTraceSpan());
|
|
34495
|
+
isAckRequired(_envelope) {
|
|
34496
|
+
return false;
|
|
34472
34497
|
}
|
|
34473
34498
|
}
|
|
34474
34499
|
|
|
34475
|
-
|
|
34476
|
-
base: TRACE_EMITTER_FACTORY_BASE_TYPE,
|
|
34477
|
-
key: 'NoopTraceEmitter',
|
|
34478
|
-
};
|
|
34479
|
-
class NoopTraceEmitterFactory extends TraceEmitterFactory {
|
|
34500
|
+
class AtMostOnceDeliveryPolicyFactory extends DeliveryPolicyFactory {
|
|
34480
34501
|
constructor() {
|
|
34481
34502
|
super(...arguments);
|
|
34482
|
-
this.type = '
|
|
34483
|
-
this.isDefault = true;
|
|
34484
|
-
this.priority = 100;
|
|
34503
|
+
this.type = 'AtMostOnceDeliveryPolicy';
|
|
34485
34504
|
}
|
|
34486
|
-
async create() {
|
|
34487
|
-
return new
|
|
34505
|
+
async create(_config) {
|
|
34506
|
+
return new AtMostOnceDeliveryPolicy();
|
|
34488
34507
|
}
|
|
34489
34508
|
}
|
|
34509
|
+
registerDeliveryPolicyFactory('AtMostOnceDeliveryPolicy', AtMostOnceDeliveryPolicyFactory);
|
|
34510
|
+
registerDeliveryPolicyFactory('AtMostOnceMessageDeliveryPolicy', AtMostOnceDeliveryPolicyFactory);
|
|
34511
|
+
const FACTORY_META$Q = {
|
|
34512
|
+
base: DELIVERY_POLICY_FACTORY_BASE_TYPE,
|
|
34513
|
+
key: 'AtMostOnceDeliveryPolicy',
|
|
34514
|
+
};
|
|
34490
34515
|
|
|
34491
|
-
var
|
|
34516
|
+
var atMostOnceDeliveryPolicyFactory = /*#__PURE__*/Object.freeze({
|
|
34492
34517
|
__proto__: null,
|
|
34493
|
-
|
|
34494
|
-
|
|
34495
|
-
default:
|
|
34518
|
+
AtMostOnceDeliveryPolicyFactory: AtMostOnceDeliveryPolicyFactory,
|
|
34519
|
+
FACTORY_META: FACTORY_META$Q,
|
|
34520
|
+
default: AtMostOnceDeliveryPolicyFactory
|
|
34496
34521
|
});
|
|
34497
34522
|
|
|
34498
|
-
|
|
34499
|
-
let otelApiModulePromise = null;
|
|
34500
|
-
let otelSetupModulePromise = null;
|
|
34501
|
-
const logger$h = getLogger('naylence.fame.telemetry.open_telemetry_trace_emitter_factory');
|
|
34502
|
-
const MISSING_OTEL_HELP_MESSAGE = 'Missing optional OpenTelemetry dependency. Install @opentelemetry/api (and related packages) to enable trace emission.';
|
|
34503
|
-
function getOpenTelemetryTraceEmitterModule() {
|
|
34504
|
-
if (!openTelemetryTraceEmitterModulePromise) {
|
|
34505
|
-
openTelemetryTraceEmitterModulePromise = safeImport(() => Promise.resolve().then(function () { return openTelemetryTraceEmitter; }), '@opentelemetry/api', {
|
|
34506
|
-
helpMessage: MISSING_OTEL_HELP_MESSAGE,
|
|
34507
|
-
});
|
|
34508
|
-
}
|
|
34509
|
-
return openTelemetryTraceEmitterModulePromise;
|
|
34510
|
-
}
|
|
34511
|
-
function getOtelApiModule() {
|
|
34512
|
-
if (!otelApiModulePromise) {
|
|
34513
|
-
otelApiModulePromise = safeImport(() => import('@opentelemetry/api'), '@opentelemetry/api', {
|
|
34514
|
-
helpMessage: MISSING_OTEL_HELP_MESSAGE,
|
|
34515
|
-
});
|
|
34516
|
-
}
|
|
34517
|
-
return otelApiModulePromise;
|
|
34518
|
-
}
|
|
34519
|
-
function getOtelSetupModule() {
|
|
34520
|
-
if (!otelSetupModulePromise) {
|
|
34521
|
-
otelSetupModulePromise = safeImport(() => Promise.resolve().then(function () { return otelSetup; }), '@opentelemetry/api', {
|
|
34522
|
-
helpMessage: MISSING_OTEL_HELP_MESSAGE,
|
|
34523
|
-
});
|
|
34524
|
-
}
|
|
34525
|
-
return otelSetupModulePromise;
|
|
34526
|
-
}
|
|
34527
|
-
const FACTORY_META$Q = {
|
|
34528
|
-
base: TRACE_EMITTER_FACTORY_BASE_TYPE,
|
|
34529
|
-
key: 'OpenTelemetryTraceEmitter',
|
|
34530
|
-
};
|
|
34531
|
-
class OpenTelemetryTraceEmitterFactory extends TraceEmitterFactory {
|
|
34532
|
-
constructor() {
|
|
34533
|
-
super(...arguments);
|
|
34534
|
-
this.type = 'OpenTelemetryTraceEmitter';
|
|
34535
|
-
}
|
|
34536
|
-
async create(config, ...factoryArgs) {
|
|
34537
|
-
const options = (factoryArgs[0] ??
|
|
34538
|
-
{});
|
|
34539
|
-
const normalized = normalizeConfig$n(config);
|
|
34540
|
-
const mergedHeaders = {
|
|
34541
|
-
...normalized.headers,
|
|
34542
|
-
...(options.headers ?? {}),
|
|
34543
|
-
};
|
|
34544
|
-
let authStrategy = null;
|
|
34545
|
-
if (normalized.auth) {
|
|
34546
|
-
authStrategy =
|
|
34547
|
-
await AuthInjectionStrategyFactory.createAuthInjectionStrategy(normalized.auth);
|
|
34548
|
-
try {
|
|
34549
|
-
await authStrategy.apply(mergedHeaders);
|
|
34550
|
-
logger$h.info('trace_emitter_auth_applied', {
|
|
34551
|
-
service_name: normalized.serviceName,
|
|
34552
|
-
});
|
|
34553
|
-
}
|
|
34554
|
-
catch (error) {
|
|
34555
|
-
try {
|
|
34556
|
-
await authStrategy.cleanup();
|
|
34557
|
-
}
|
|
34558
|
-
catch {
|
|
34559
|
-
// Ignore cleanup errors while propagating original failure
|
|
34560
|
-
}
|
|
34561
|
-
throw error;
|
|
34562
|
-
}
|
|
34563
|
-
}
|
|
34564
|
-
let lifecycle = null;
|
|
34565
|
-
try {
|
|
34566
|
-
const { setupOtel } = await getOtelSetupModule();
|
|
34567
|
-
lifecycle = await setupOtel({
|
|
34568
|
-
serviceName: normalized.serviceName,
|
|
34569
|
-
endpoint: normalized.endpoint,
|
|
34570
|
-
environment: normalized.environment,
|
|
34571
|
-
sampler: normalized.sampler,
|
|
34572
|
-
headers: Object.keys(mergedHeaders).length > 0 ? mergedHeaders : undefined,
|
|
34573
|
-
});
|
|
34574
|
-
logger$h.debug('trace_emitter_lifecycle_acquired', {
|
|
34575
|
-
service_name: normalized.serviceName,
|
|
34576
|
-
lifecycle_available: Boolean(lifecycle),
|
|
34577
|
-
});
|
|
34578
|
-
}
|
|
34579
|
-
catch (error) {
|
|
34580
|
-
if (authStrategy) {
|
|
34581
|
-
try {
|
|
34582
|
-
await authStrategy.cleanup();
|
|
34583
|
-
}
|
|
34584
|
-
catch {
|
|
34585
|
-
// Ignore cleanup errors while propagating original failure
|
|
34586
|
-
}
|
|
34587
|
-
}
|
|
34588
|
-
throw error;
|
|
34589
|
-
}
|
|
34590
|
-
const [{ OpenTelemetryTraceEmitter }, otelModule] = await Promise.all([
|
|
34591
|
-
getOpenTelemetryTraceEmitterModule(),
|
|
34592
|
-
getOtelApiModule(),
|
|
34593
|
-
]);
|
|
34594
|
-
const emitterOptions = {
|
|
34595
|
-
serviceName: normalized.serviceName,
|
|
34596
|
-
otelApi: {
|
|
34597
|
-
trace: otelModule.trace,
|
|
34598
|
-
SpanStatusCode: otelModule.SpanStatusCode,
|
|
34599
|
-
},
|
|
34600
|
-
};
|
|
34601
|
-
if (options.tracer) {
|
|
34602
|
-
emitterOptions.tracer = options.tracer;
|
|
34603
|
-
}
|
|
34604
|
-
if (lifecycle) {
|
|
34605
|
-
emitterOptions.lifecycle = lifecycle;
|
|
34606
|
-
}
|
|
34607
|
-
if (authStrategy) {
|
|
34608
|
-
emitterOptions.authStrategy = authStrategy;
|
|
34609
|
-
}
|
|
34610
|
-
try {
|
|
34611
|
-
const emitter = new OpenTelemetryTraceEmitter(emitterOptions);
|
|
34612
|
-
logger$h.debug('trace_emitter_created', {
|
|
34613
|
-
service_name: normalized.serviceName,
|
|
34614
|
-
has_lifecycle: Boolean(lifecycle),
|
|
34615
|
-
has_auth_strategy: Boolean(authStrategy),
|
|
34616
|
-
});
|
|
34617
|
-
return emitter;
|
|
34618
|
-
}
|
|
34619
|
-
catch (error) {
|
|
34620
|
-
if (authStrategy) {
|
|
34621
|
-
try {
|
|
34622
|
-
await authStrategy.cleanup();
|
|
34623
|
-
}
|
|
34624
|
-
catch {
|
|
34625
|
-
// Best effort cleanup
|
|
34626
|
-
}
|
|
34627
|
-
}
|
|
34628
|
-
throw error;
|
|
34629
|
-
}
|
|
34630
|
-
}
|
|
34631
|
-
}
|
|
34632
|
-
function normalizeConfig$n(config) {
|
|
34633
|
-
if (!config) {
|
|
34634
|
-
return {
|
|
34635
|
-
serviceName: 'naylence-service',
|
|
34636
|
-
endpoint: null,
|
|
34637
|
-
environment: null,
|
|
34638
|
-
sampler: null,
|
|
34639
|
-
headers: {},
|
|
34640
|
-
auth: null,
|
|
34641
|
-
};
|
|
34642
|
-
}
|
|
34643
|
-
const candidate = config;
|
|
34644
|
-
const serviceName = extractString(pickFirst$2(candidate, ['serviceName', 'service_name'])) ??
|
|
34645
|
-
'naylence-service';
|
|
34646
|
-
const endpoint = extractString(pickFirst$2(candidate, ['endpoint', 'otlpEndpoint', 'otlp_endpoint'])) ?? null;
|
|
34647
|
-
const environment = extractString(pickFirst$2(candidate, [
|
|
34648
|
-
'environment',
|
|
34649
|
-
'deploymentEnvironment',
|
|
34650
|
-
'deployment_environment',
|
|
34651
|
-
])) ?? null;
|
|
34652
|
-
const sampler = extractString(pickFirst$2(candidate, ['sampler', 'samplingStrategy', 'sampling_strategy'])) ?? null;
|
|
34653
|
-
const headersFromConfig = extractHeaders$1(pickFirst$2(candidate, ['headers', 'otlpHeaders', 'otlp_headers']));
|
|
34654
|
-
const authConfig = pickFirst$2(candidate, [
|
|
34655
|
-
'auth',
|
|
34656
|
-
]);
|
|
34657
|
-
return {
|
|
34658
|
-
serviceName,
|
|
34659
|
-
endpoint,
|
|
34660
|
-
environment,
|
|
34661
|
-
sampler,
|
|
34662
|
-
headers: headersFromConfig ?? {},
|
|
34663
|
-
auth: authConfig ?? null,
|
|
34664
|
-
};
|
|
34665
|
-
}
|
|
34666
|
-
function extractString(value) {
|
|
34667
|
-
if (typeof value === 'string' && value.trim().length > 0) {
|
|
34668
|
-
return value;
|
|
34669
|
-
}
|
|
34670
|
-
return undefined;
|
|
34671
|
-
}
|
|
34672
|
-
function pickFirst$2(source, keys) {
|
|
34673
|
-
for (const key of keys) {
|
|
34674
|
-
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
34675
|
-
const value = source[key];
|
|
34676
|
-
if (value !== undefined) {
|
|
34677
|
-
return value;
|
|
34678
|
-
}
|
|
34679
|
-
}
|
|
34680
|
-
}
|
|
34681
|
-
return undefined;
|
|
34682
|
-
}
|
|
34683
|
-
function extractHeaders$1(value) {
|
|
34684
|
-
if (!value || typeof value !== 'object') {
|
|
34685
|
-
return null;
|
|
34686
|
-
}
|
|
34687
|
-
const headers = {};
|
|
34688
|
-
for (const [key, raw] of Object.entries(value)) {
|
|
34689
|
-
if (typeof raw === 'string') {
|
|
34690
|
-
headers[key] = raw;
|
|
34691
|
-
}
|
|
34692
|
-
}
|
|
34693
|
-
return Object.keys(headers).length > 0 ? headers : null;
|
|
34694
|
-
}
|
|
34695
|
-
|
|
34696
|
-
var openTelemetryTraceEmitterFactory = /*#__PURE__*/Object.freeze({
|
|
34697
|
-
__proto__: null,
|
|
34698
|
-
FACTORY_META: FACTORY_META$Q,
|
|
34699
|
-
OpenTelemetryTraceEmitterFactory: OpenTelemetryTraceEmitterFactory,
|
|
34700
|
-
default: OpenTelemetryTraceEmitterFactory
|
|
34701
|
-
});
|
|
34702
|
-
|
|
34703
|
-
const logger$g = getLogger('naylence.fame.telemetry.trace_emitter_profile_factory');
|
|
34704
|
-
const PROFILE_NAME_NOOP$1 = 'noop';
|
|
34705
|
-
const PROFILE_NAME_OPEN_TELEMETRY = 'open-telemetry';
|
|
34706
|
-
const ENV_VAR_TELEMETRY_SERVICE_NAME = 'FAME_TELEMETRY_SERVICE_NAME';
|
|
34707
|
-
const NOOP_PROFILE$1 = {
|
|
34708
|
-
type: 'NoopTraceEmitter',
|
|
34709
|
-
};
|
|
34710
|
-
const OPEN_TELEMETRY_PROFILE = {
|
|
34711
|
-
type: 'OpenTelemetryTraceEmitter',
|
|
34712
|
-
serviceName: factory.Expressions.env(ENV_VAR_TELEMETRY_SERVICE_NAME, 'naylence-service'),
|
|
34713
|
-
headers: {},
|
|
34714
|
-
};
|
|
34715
|
-
const PROFILE_MAP$3 = {
|
|
34716
|
-
[PROFILE_NAME_NOOP$1]: NOOP_PROFILE$1,
|
|
34717
|
-
[PROFILE_NAME_OPEN_TELEMETRY]: OPEN_TELEMETRY_PROFILE,
|
|
34718
|
-
};
|
|
34719
|
-
const FACTORY_META$P = {
|
|
34720
|
-
base: TRACE_EMITTER_FACTORY_BASE_TYPE,
|
|
34721
|
-
key: 'TraceEmitterProfile',
|
|
34722
|
-
};
|
|
34723
|
-
class TraceEmitterProfileFactory extends TraceEmitterFactory {
|
|
34724
|
-
constructor() {
|
|
34725
|
-
super(...arguments);
|
|
34726
|
-
this.type = 'TraceEmitterProfile';
|
|
34727
|
-
}
|
|
34728
|
-
async create(config, ...factoryArgs) {
|
|
34729
|
-
const normalized = normalizeTraceEmitterProfileConfig(config);
|
|
34730
|
-
const profileConfig = resolveProfileConfig$2(normalized.profile);
|
|
34731
|
-
logger$g.debug('enabling_trace_emitter_profile', {
|
|
34732
|
-
profile: normalized.profile,
|
|
34733
|
-
});
|
|
34734
|
-
const traceEmitter = await TraceEmitterFactory.createTraceEmitter(profileConfig, {
|
|
34735
|
-
factoryArgs,
|
|
34736
|
-
});
|
|
34737
|
-
if (!traceEmitter) {
|
|
34738
|
-
throw new Error(`Failed to instantiate trace emitter profile: ${normalized.profile}`);
|
|
34739
|
-
}
|
|
34740
|
-
return traceEmitter;
|
|
34741
|
-
}
|
|
34742
|
-
}
|
|
34743
|
-
function normalizeTraceEmitterProfileConfig(config) {
|
|
34744
|
-
if (!config) {
|
|
34745
|
-
return { profile: PROFILE_NAME_NOOP$1 };
|
|
34746
|
-
}
|
|
34747
|
-
const candidate = config;
|
|
34748
|
-
const profileValue = resolveProfileName$1(candidate);
|
|
34749
|
-
const canonicalProfile = canonicalizeProfileName(profileValue);
|
|
34750
|
-
candidate.profile = canonicalProfile;
|
|
34751
|
-
return { profile: canonicalProfile };
|
|
34752
|
-
}
|
|
34753
|
-
function resolveProfileName$1(candidate) {
|
|
34754
|
-
const direct = coerceProfileString$1(candidate.profile);
|
|
34755
|
-
if (direct) {
|
|
34756
|
-
return direct;
|
|
34757
|
-
}
|
|
34758
|
-
const legacyKeys = ['profile_name', 'profileName'];
|
|
34759
|
-
for (const legacyKey of legacyKeys) {
|
|
34760
|
-
const legacyValue = coerceProfileString$1(candidate[legacyKey]);
|
|
34761
|
-
if (legacyValue) {
|
|
34762
|
-
return legacyValue;
|
|
34763
|
-
}
|
|
34764
|
-
}
|
|
34765
|
-
return PROFILE_NAME_NOOP$1;
|
|
34766
|
-
}
|
|
34767
|
-
function coerceProfileString$1(value) {
|
|
34768
|
-
if (typeof value !== 'string') {
|
|
34769
|
-
return null;
|
|
34770
|
-
}
|
|
34771
|
-
const trimmed = value.trim();
|
|
34772
|
-
return trimmed.length > 0 ? trimmed : null;
|
|
34773
|
-
}
|
|
34774
|
-
const PROFILE_ALIASES = {
|
|
34775
|
-
noop: PROFILE_NAME_NOOP$1,
|
|
34776
|
-
'no-op': PROFILE_NAME_NOOP$1,
|
|
34777
|
-
no_op: PROFILE_NAME_NOOP$1,
|
|
34778
|
-
'open-telemetry': PROFILE_NAME_OPEN_TELEMETRY,
|
|
34779
|
-
open_telemetry: PROFILE_NAME_OPEN_TELEMETRY,
|
|
34780
|
-
opentelemetry: PROFILE_NAME_OPEN_TELEMETRY,
|
|
34781
|
-
};
|
|
34782
|
-
function canonicalizeProfileName(value) {
|
|
34783
|
-
const normalized = value.replace(/[\s_]+/g, '-').toLowerCase();
|
|
34784
|
-
return PROFILE_ALIASES[normalized] ?? normalized;
|
|
34785
|
-
}
|
|
34786
|
-
function resolveProfileConfig$2(profileName) {
|
|
34787
|
-
const profile = PROFILE_MAP$3[profileName];
|
|
34788
|
-
if (!profile) {
|
|
34789
|
-
throw new Error(`Unknown trace emitter profile: ${profileName}`);
|
|
34790
|
-
}
|
|
34791
|
-
return deepClone$2(profile);
|
|
34792
|
-
}
|
|
34793
|
-
function deepClone$2(value) {
|
|
34794
|
-
return JSON.parse(JSON.stringify(value));
|
|
34795
|
-
}
|
|
34796
|
-
|
|
34797
|
-
var traceEmitterProfileFactory = /*#__PURE__*/Object.freeze({
|
|
34798
|
-
__proto__: null,
|
|
34799
|
-
FACTORY_META: FACTORY_META$P,
|
|
34800
|
-
PROFILE_NAME_NOOP: PROFILE_NAME_NOOP$1,
|
|
34801
|
-
PROFILE_NAME_OPEN_TELEMETRY: PROFILE_NAME_OPEN_TELEMETRY,
|
|
34802
|
-
TraceEmitterProfileFactory: TraceEmitterProfileFactory,
|
|
34803
|
-
default: TraceEmitterProfileFactory
|
|
34804
|
-
});
|
|
34805
|
-
|
|
34806
|
-
/**
|
|
34807
|
-
* Base abstraction for message delivery policies.
|
|
34808
|
-
*/
|
|
34809
|
-
class DeliveryPolicy {
|
|
34810
|
-
constructor(options = {}) {
|
|
34811
|
-
this.senderPolicy = options.senderRetryPolicy;
|
|
34812
|
-
this.receiverPolicy = options.receiverRetryPolicy;
|
|
34813
|
-
}
|
|
34814
|
-
/**
|
|
34815
|
-
* Determine if the policy requires an acknowledgement for the envelope.
|
|
34816
|
-
*/
|
|
34817
|
-
isAckRequired(_envelope) {
|
|
34818
|
-
return false;
|
|
34819
|
-
}
|
|
34820
|
-
get senderRetryPolicy() {
|
|
34821
|
-
return this.senderPolicy;
|
|
34822
|
-
}
|
|
34823
|
-
get receiverRetryPolicy() {
|
|
34824
|
-
return this.receiverPolicy;
|
|
34825
|
-
}
|
|
34826
|
-
}
|
|
34827
|
-
|
|
34828
|
-
/**
|
|
34829
|
-
* Message delivery policy that ensures envelopes are delivered at least once.
|
|
34830
|
-
*/
|
|
34831
|
-
class AtLeastOnceDeliveryPolicy extends DeliveryPolicy {
|
|
34832
|
-
constructor(options = {}) {
|
|
34833
|
-
super(options);
|
|
34834
|
-
}
|
|
34835
|
-
isAckRequired(envelope) {
|
|
34836
|
-
const frame = envelope?.frame;
|
|
34837
|
-
const frameType = typeof frame?.type === 'string' ? frame.type : null;
|
|
34838
|
-
if (!frameType) {
|
|
34839
|
-
return false;
|
|
34840
|
-
}
|
|
34841
|
-
return frameType === 'Data' || frameType === 'DataFrame';
|
|
34842
|
-
}
|
|
34843
|
-
}
|
|
34844
|
-
|
|
34845
|
-
/**
|
|
34846
|
-
* Configuration and helper for retry backoff behaviour.
|
|
34847
|
-
*/
|
|
34848
|
-
class RetryPolicy {
|
|
34849
|
-
constructor(options = {}) {
|
|
34850
|
-
this.maxRetries = Math.max(0, Math.trunc(options.maxRetries ?? 0));
|
|
34851
|
-
this.baseDelayMs = Math.max(0, Math.trunc(options.baseDelayMs ?? 200));
|
|
34852
|
-
this.maxDelayMs = Math.max(this.baseDelayMs, Math.trunc(options.maxDelayMs ?? 10000));
|
|
34853
|
-
this.jitterMs = Math.max(0, Math.trunc(options.jitterMs ?? 50));
|
|
34854
|
-
this.backoffFactor = Math.max(0, options.backoffFactor ?? 2.0);
|
|
34855
|
-
}
|
|
34856
|
-
/**
|
|
34857
|
-
* Calculate the next retry delay based on attempt number (0-indexed).
|
|
34858
|
-
*/
|
|
34859
|
-
nextDelayMs(attempt) {
|
|
34860
|
-
const normalizedAttempt = Number.isFinite(attempt)
|
|
34861
|
-
? Math.max(0, Math.trunc(attempt))
|
|
34862
|
-
: 0;
|
|
34863
|
-
const base = normalizedAttempt <= 0
|
|
34864
|
-
? this.baseDelayMs
|
|
34865
|
-
: Math.round(this.baseDelayMs * this.backoffFactor ** normalizedAttempt);
|
|
34866
|
-
const jitter = this.jitterMs > 0
|
|
34867
|
-
? Math.round((Math.random() * 2 - 1) * this.jitterMs)
|
|
34868
|
-
: 0;
|
|
34869
|
-
const withJitter = base + jitter;
|
|
34870
|
-
return Math.min(this.maxDelayMs, Math.max(0, withJitter));
|
|
34871
|
-
}
|
|
34872
|
-
}
|
|
34873
|
-
|
|
34874
|
-
const LEGACY_POLICY_KEYS = {
|
|
34875
|
-
senderRetryPolicy: ['sender_retry_policy', 'sender_retryPolicy'],
|
|
34876
|
-
receiverRetryPolicy: ['receiver_retry_policy', 'receiver_retryPolicy'],
|
|
34877
|
-
};
|
|
34878
|
-
class AtLeastOnceDeliveryPolicyFactory extends DeliveryPolicyFactory {
|
|
34879
|
-
constructor() {
|
|
34880
|
-
super(...arguments);
|
|
34881
|
-
this.type = 'AtLeastOnceDeliveryPolicy';
|
|
34882
|
-
this.isDefault = true;
|
|
34883
|
-
}
|
|
34884
|
-
async create(config) {
|
|
34885
|
-
const normalized = normalizeAtLeastOnceConfig(config);
|
|
34886
|
-
const options = {
|
|
34887
|
-
...(normalized.senderRetryPolicy
|
|
34888
|
-
? { senderRetryPolicy: normalized.senderRetryPolicy }
|
|
34889
|
-
: {}),
|
|
34890
|
-
...(normalized.receiverRetryPolicy
|
|
34891
|
-
? { receiverRetryPolicy: normalized.receiverRetryPolicy }
|
|
34892
|
-
: {}),
|
|
34893
|
-
};
|
|
34894
|
-
return new AtLeastOnceDeliveryPolicy(options);
|
|
34895
|
-
}
|
|
34896
|
-
}
|
|
34897
|
-
function normalizeAtLeastOnceConfig(config) {
|
|
34898
|
-
if (!config) {
|
|
34899
|
-
return {};
|
|
34900
|
-
}
|
|
34901
|
-
const candidate = config;
|
|
34902
|
-
const senderPolicyInput = getRetryPolicyInput(candidate, 'senderRetryPolicy');
|
|
34903
|
-
const receiverPolicyInput = getRetryPolicyInput(candidate, 'receiverRetryPolicy');
|
|
34904
|
-
return {
|
|
34905
|
-
senderRetryPolicy: resolveRetryPolicy(senderPolicyInput),
|
|
34906
|
-
receiverRetryPolicy: resolveRetryPolicy(receiverPolicyInput),
|
|
34907
|
-
};
|
|
34908
|
-
}
|
|
34909
|
-
function getRetryPolicyInput(candidate, key) {
|
|
34910
|
-
const camelKey = key;
|
|
34911
|
-
const primary = candidate[camelKey];
|
|
34912
|
-
if (primary !== undefined) {
|
|
34913
|
-
return primary;
|
|
34914
|
-
}
|
|
34915
|
-
const legacyKeys = LEGACY_POLICY_KEYS[key] ?? [];
|
|
34916
|
-
for (const legacyKey of legacyKeys) {
|
|
34917
|
-
const value = candidate[legacyKey];
|
|
34918
|
-
if (value !== undefined) {
|
|
34919
|
-
candidate[camelKey] = value;
|
|
34920
|
-
return value;
|
|
34921
|
-
}
|
|
34922
|
-
}
|
|
34923
|
-
return undefined;
|
|
34924
|
-
}
|
|
34925
|
-
function resolveRetryPolicy(input) {
|
|
34926
|
-
if (!input) {
|
|
34927
|
-
return undefined;
|
|
34928
|
-
}
|
|
34929
|
-
if (input instanceof RetryPolicy) {
|
|
34930
|
-
return input;
|
|
34931
|
-
}
|
|
34932
|
-
const record = input;
|
|
34933
|
-
const options = {
|
|
34934
|
-
...(withOption(record, ['maxRetries', 'max_retries']) ?? {}),
|
|
34935
|
-
...(withOption(record, ['baseDelayMs', 'base_delay_ms']) ?? {}),
|
|
34936
|
-
...(withOption(record, ['maxDelayMs', 'max_delay_ms']) ?? {}),
|
|
34937
|
-
...(withOption(record, ['jitterMs', 'jitter_ms']) ?? {}),
|
|
34938
|
-
...(withOption(record, ['backoffFactor', 'backoff_factor']) ?? {}),
|
|
34939
|
-
};
|
|
34940
|
-
return new RetryPolicy(options);
|
|
34941
|
-
}
|
|
34942
|
-
function extractNumber(source, keys) {
|
|
34943
|
-
for (const key of keys) {
|
|
34944
|
-
if (key in source) {
|
|
34945
|
-
const value = source[key];
|
|
34946
|
-
if (typeof value === 'number' && Number.isFinite(value)) {
|
|
34947
|
-
return value;
|
|
34948
|
-
}
|
|
34949
|
-
if (typeof value === 'string' && value.trim().length > 0) {
|
|
34950
|
-
const parsed = Number(value);
|
|
34951
|
-
if (!Number.isNaN(parsed)) {
|
|
34952
|
-
return parsed;
|
|
34953
|
-
}
|
|
34954
|
-
}
|
|
34955
|
-
}
|
|
34956
|
-
}
|
|
34957
|
-
return undefined;
|
|
34958
|
-
}
|
|
34959
|
-
function withOption(source, keys) {
|
|
34960
|
-
const value = extractNumber(source, keys);
|
|
34961
|
-
if (value === undefined) {
|
|
34962
|
-
return undefined;
|
|
34963
|
-
}
|
|
34964
|
-
const camelKey = keys[0];
|
|
34965
|
-
return {
|
|
34966
|
-
[camelKey]: value,
|
|
34967
|
-
};
|
|
34968
|
-
}
|
|
34969
|
-
const FACTORY_META$O = {
|
|
34970
|
-
base: DELIVERY_POLICY_FACTORY_BASE_TYPE,
|
|
34971
|
-
key: 'AtLeastOnceDeliveryPolicy',
|
|
34972
|
-
};
|
|
34973
|
-
|
|
34974
|
-
var atLeastOnceDeliveryPolicyFactory = /*#__PURE__*/Object.freeze({
|
|
34975
|
-
__proto__: null,
|
|
34976
|
-
AtLeastOnceDeliveryPolicyFactory: AtLeastOnceDeliveryPolicyFactory,
|
|
34977
|
-
FACTORY_META: FACTORY_META$O,
|
|
34978
|
-
default: AtLeastOnceDeliveryPolicyFactory
|
|
34979
|
-
});
|
|
34980
|
-
|
|
34981
|
-
/**
|
|
34982
|
-
* Message delivery policy that ensures envelopes are delivered at most once.
|
|
34983
|
-
*/
|
|
34984
|
-
class AtMostOnceDeliveryPolicy extends DeliveryPolicy {
|
|
34985
|
-
constructor() {
|
|
34986
|
-
super();
|
|
34987
|
-
}
|
|
34988
|
-
isAckRequired(_envelope) {
|
|
34989
|
-
return false;
|
|
34990
|
-
}
|
|
34991
|
-
}
|
|
34992
|
-
|
|
34993
|
-
class AtMostOnceDeliveryPolicyFactory extends DeliveryPolicyFactory {
|
|
34994
|
-
constructor() {
|
|
34995
|
-
super(...arguments);
|
|
34996
|
-
this.type = 'AtMostOnceDeliveryPolicy';
|
|
34997
|
-
}
|
|
34998
|
-
async create(_config) {
|
|
34999
|
-
return new AtMostOnceDeliveryPolicy();
|
|
35000
|
-
}
|
|
35001
|
-
}
|
|
35002
|
-
registerDeliveryPolicyFactory('AtMostOnceDeliveryPolicy', AtMostOnceDeliveryPolicyFactory);
|
|
35003
|
-
registerDeliveryPolicyFactory('AtMostOnceMessageDeliveryPolicy', AtMostOnceDeliveryPolicyFactory);
|
|
35004
|
-
const FACTORY_META$N = {
|
|
35005
|
-
base: DELIVERY_POLICY_FACTORY_BASE_TYPE,
|
|
35006
|
-
key: 'AtMostOnceDeliveryPolicy',
|
|
35007
|
-
};
|
|
35008
|
-
|
|
35009
|
-
var atMostOnceDeliveryPolicyFactory = /*#__PURE__*/Object.freeze({
|
|
35010
|
-
__proto__: null,
|
|
35011
|
-
AtMostOnceDeliveryPolicyFactory: AtMostOnceDeliveryPolicyFactory,
|
|
35012
|
-
FACTORY_META: FACTORY_META$N,
|
|
35013
|
-
default: AtMostOnceDeliveryPolicyFactory
|
|
35014
|
-
});
|
|
35015
|
-
|
|
35016
|
-
const logger$f = getLogger('naylence.fame.delivery.delivery_profile_factory');
|
|
34523
|
+
const logger$h = getLogger('naylence.fame.delivery.delivery_profile_factory');
|
|
35017
34524
|
const PROFILE_NAME_AT_LEAST_ONCE = 'at-least-once';
|
|
35018
34525
|
const PROFILE_NAME_AT_MOST_ONCE = 'at-most-once';
|
|
35019
34526
|
const ENV_VAR_FAME_DELIVERY_MAX_RETRIES = 'FAME_DELIVERY_MAX_RETRIES';
|
|
@@ -35041,7 +34548,7 @@ const AT_LEAST_ONCE_PROFILE = {
|
|
|
35041
34548
|
const AT_MOST_ONCE_PROFILE = {
|
|
35042
34549
|
type: 'AtMostOnceDeliveryPolicy',
|
|
35043
34550
|
};
|
|
35044
|
-
const PROFILE_MAP$
|
|
34551
|
+
const PROFILE_MAP$3 = {
|
|
35045
34552
|
[PROFILE_NAME_AT_LEAST_ONCE]: AT_LEAST_ONCE_PROFILE,
|
|
35046
34553
|
[PROFILE_NAME_AT_MOST_ONCE]: AT_MOST_ONCE_PROFILE,
|
|
35047
34554
|
};
|
|
@@ -35052,8 +34559,8 @@ class DeliveryProfileFactory extends DeliveryPolicyFactory {
|
|
|
35052
34559
|
}
|
|
35053
34560
|
async create(config) {
|
|
35054
34561
|
const normalized = normalizeDeliveryProfileConfig(config);
|
|
35055
|
-
const profileConfig = resolveProfileConfig$
|
|
35056
|
-
logger$
|
|
34562
|
+
const profileConfig = resolveProfileConfig$2(normalized.profile);
|
|
34563
|
+
logger$h.debug('enabling_delivery_profile', { profile: normalized.profile });
|
|
35057
34564
|
const policy = await DeliveryPolicyFactory.createDeliveryPolicy(profileConfig);
|
|
35058
34565
|
if (!policy) {
|
|
35059
34566
|
throw new Error(`Failed to create delivery policy for profile: ${normalized.profile}`);
|
|
@@ -35066,18 +34573,18 @@ function normalizeDeliveryProfileConfig(config) {
|
|
|
35066
34573
|
return { profile: PROFILE_NAME_AT_LEAST_ONCE };
|
|
35067
34574
|
}
|
|
35068
34575
|
const candidate = config;
|
|
35069
|
-
const profileValue = resolveProfileName(candidate);
|
|
34576
|
+
const profileValue = resolveProfileName$1(candidate);
|
|
35070
34577
|
candidate.profile = profileValue;
|
|
35071
34578
|
return { profile: profileValue.toLowerCase() };
|
|
35072
34579
|
}
|
|
35073
|
-
function resolveProfileName(candidate) {
|
|
35074
|
-
const value = coerceProfileString(candidate.profile);
|
|
34580
|
+
function resolveProfileName$1(candidate) {
|
|
34581
|
+
const value = coerceProfileString$1(candidate.profile);
|
|
35075
34582
|
if (value) {
|
|
35076
34583
|
return value;
|
|
35077
34584
|
}
|
|
35078
34585
|
const legacyKeys = ['profile_name', 'profileName'];
|
|
35079
34586
|
for (const legacyKey of legacyKeys) {
|
|
35080
|
-
const legacyValue = coerceProfileString(candidate[legacyKey]);
|
|
34587
|
+
const legacyValue = coerceProfileString$1(candidate[legacyKey]);
|
|
35081
34588
|
if (legacyValue) {
|
|
35082
34589
|
candidate.profile = legacyValue;
|
|
35083
34590
|
return legacyValue;
|
|
@@ -35085,24 +34592,24 @@ function resolveProfileName(candidate) {
|
|
|
35085
34592
|
}
|
|
35086
34593
|
return PROFILE_NAME_AT_LEAST_ONCE;
|
|
35087
34594
|
}
|
|
35088
|
-
function coerceProfileString(value) {
|
|
34595
|
+
function coerceProfileString$1(value) {
|
|
35089
34596
|
if (typeof value !== 'string') {
|
|
35090
34597
|
return null;
|
|
35091
34598
|
}
|
|
35092
34599
|
const trimmed = value.trim();
|
|
35093
34600
|
return trimmed.length > 0 ? trimmed : null;
|
|
35094
34601
|
}
|
|
35095
|
-
function resolveProfileConfig$
|
|
35096
|
-
const profile = PROFILE_MAP$
|
|
34602
|
+
function resolveProfileConfig$2(profileName) {
|
|
34603
|
+
const profile = PROFILE_MAP$3[profileName];
|
|
35097
34604
|
if (!profile) {
|
|
35098
34605
|
throw new Error(`Unknown delivery profile: ${profileName}`);
|
|
35099
34606
|
}
|
|
35100
|
-
return deepClone$
|
|
34607
|
+
return deepClone$2(profile);
|
|
35101
34608
|
}
|
|
35102
|
-
function deepClone$
|
|
34609
|
+
function deepClone$2(value) {
|
|
35103
34610
|
return JSON.parse(JSON.stringify(value));
|
|
35104
34611
|
}
|
|
35105
|
-
const FACTORY_META$
|
|
34612
|
+
const FACTORY_META$P = {
|
|
35106
34613
|
base: DELIVERY_POLICY_FACTORY_BASE_TYPE,
|
|
35107
34614
|
key: 'DeliveryProfile',
|
|
35108
34615
|
};
|
|
@@ -35110,13 +34617,13 @@ const FACTORY_META$M = {
|
|
|
35110
34617
|
var deliveryProfileFactory = /*#__PURE__*/Object.freeze({
|
|
35111
34618
|
__proto__: null,
|
|
35112
34619
|
DeliveryProfileFactory: DeliveryProfileFactory,
|
|
35113
|
-
FACTORY_META: FACTORY_META$
|
|
34620
|
+
FACTORY_META: FACTORY_META$P,
|
|
35114
34621
|
PROFILE_NAME_AT_LEAST_ONCE: PROFILE_NAME_AT_LEAST_ONCE,
|
|
35115
34622
|
PROFILE_NAME_AT_MOST_ONCE: PROFILE_NAME_AT_MOST_ONCE,
|
|
35116
34623
|
default: DeliveryProfileFactory
|
|
35117
34624
|
});
|
|
35118
34625
|
|
|
35119
|
-
const logger$
|
|
34626
|
+
const logger$g = getLogger('naylence.fame.node.admission.admission_profile_factory');
|
|
35120
34627
|
const ENV_VAR_IS_ROOT = 'FAME_ROOT';
|
|
35121
34628
|
const ENV_VAR_JWT_AUDIENCE = 'FAME_JWT_AUDIENCE';
|
|
35122
34629
|
const ENV_VAR_ADMISSION_TOKEN_URL = 'FAME_ADMISSION_TOKEN_URL';
|
|
@@ -35140,7 +34647,7 @@ const PROFILE_NAME_DIRECT_HTTP = 'direct-http';
|
|
|
35140
34647
|
const PROFILE_NAME_DIRECT_INPAGE = 'direct-inpage';
|
|
35141
34648
|
const PROFILE_NAME_DIRECT_PKCE = 'direct-pkce';
|
|
35142
34649
|
const PROFILE_NAME_OPEN = 'open';
|
|
35143
|
-
const PROFILE_NAME_NOOP = 'noop';
|
|
34650
|
+
const PROFILE_NAME_NOOP$1 = 'noop';
|
|
35144
34651
|
const PROFILE_NAME_NONE = 'none';
|
|
35145
34652
|
const PROFILE_NAME_DIRECT_INPAGE_ALIAS = 'direct_inpage';
|
|
35146
34653
|
const PROFILE_NAME_DIRECT_PKCE_ALIAS = 'direct_pkce';
|
|
@@ -35320,12 +34827,12 @@ const OPEN_PROFILE = {
|
|
|
35320
34827
|
},
|
|
35321
34828
|
],
|
|
35322
34829
|
};
|
|
35323
|
-
const NOOP_PROFILE = {
|
|
34830
|
+
const NOOP_PROFILE$1 = {
|
|
35324
34831
|
type: 'NoopAdmissionClient',
|
|
35325
34832
|
auto_accept_logicals: true,
|
|
35326
34833
|
autoAcceptLogicals: true,
|
|
35327
34834
|
};
|
|
35328
|
-
const PROFILE_MAP$
|
|
34835
|
+
const PROFILE_MAP$2 = {
|
|
35329
34836
|
[PROFILE_NAME_WELCOME]: WELCOME_SERVICE_PROFILE,
|
|
35330
34837
|
[PROFILE_NAME_WELCOME_PKCE]: WELCOME_SERVICE_PKCE_PROFILE,
|
|
35331
34838
|
[PROFILE_NAME_WELCOME_PKCE_ALIAS]: WELCOME_SERVICE_PKCE_PROFILE,
|
|
@@ -35336,10 +34843,10 @@ const PROFILE_MAP$1 = {
|
|
|
35336
34843
|
[PROFILE_NAME_DIRECT_INPAGE]: DIRECT_INPAGE_PROFILE,
|
|
35337
34844
|
[PROFILE_NAME_DIRECT_INPAGE_ALIAS]: DIRECT_INPAGE_PROFILE,
|
|
35338
34845
|
[PROFILE_NAME_OPEN]: OPEN_PROFILE,
|
|
35339
|
-
[PROFILE_NAME_NOOP]: NOOP_PROFILE,
|
|
35340
|
-
[PROFILE_NAME_NONE]: NOOP_PROFILE,
|
|
34846
|
+
[PROFILE_NAME_NOOP$1]: NOOP_PROFILE$1,
|
|
34847
|
+
[PROFILE_NAME_NONE]: NOOP_PROFILE$1,
|
|
35341
34848
|
};
|
|
35342
|
-
const FACTORY_META$
|
|
34849
|
+
const FACTORY_META$O = {
|
|
35343
34850
|
base: ADMISSION_CLIENT_FACTORY_BASE_TYPE,
|
|
35344
34851
|
key: 'AdmissionProfile',
|
|
35345
34852
|
};
|
|
@@ -35349,13 +34856,13 @@ class AdmissionProfileFactory extends AdmissionClientFactory {
|
|
|
35349
34856
|
this.type = 'AdmissionProfile';
|
|
35350
34857
|
}
|
|
35351
34858
|
async create(config) {
|
|
35352
|
-
const normalized = normalizeConfig$
|
|
35353
|
-
const profileConfig = resolveProfileConfig(normalized.profile);
|
|
35354
|
-
logger$
|
|
34859
|
+
const normalized = normalizeConfig$n(config);
|
|
34860
|
+
const profileConfig = resolveProfileConfig$1(normalized.profile);
|
|
34861
|
+
logger$g.debug('enabling_admission_profile', { profile: normalized.profile });
|
|
35355
34862
|
return AdmissionClientFactory.createAdmissionClient(profileConfig);
|
|
35356
34863
|
}
|
|
35357
34864
|
}
|
|
35358
|
-
function normalizeConfig$
|
|
34865
|
+
function normalizeConfig$n(config) {
|
|
35359
34866
|
if (!config) {
|
|
35360
34867
|
return { profile: PROFILE_NAME_DIRECT };
|
|
35361
34868
|
}
|
|
@@ -35372,25 +34879,25 @@ function normalizeConfig$m(config) {
|
|
|
35372
34879
|
const normalizedProfile = profileValue.trim().toLowerCase();
|
|
35373
34880
|
return { profile: normalizedProfile };
|
|
35374
34881
|
}
|
|
35375
|
-
function resolveProfileConfig(profileName) {
|
|
35376
|
-
const profile = PROFILE_MAP$
|
|
34882
|
+
function resolveProfileConfig$1(profileName) {
|
|
34883
|
+
const profile = PROFILE_MAP$2[profileName];
|
|
35377
34884
|
if (!profile) {
|
|
35378
34885
|
throw new Error(`Unknown admission profile: ${profileName}`);
|
|
35379
34886
|
}
|
|
35380
|
-
return deepClone(profile);
|
|
34887
|
+
return deepClone$1(profile);
|
|
35381
34888
|
}
|
|
35382
|
-
function deepClone(value) {
|
|
34889
|
+
function deepClone$1(value) {
|
|
35383
34890
|
return JSON.parse(JSON.stringify(value));
|
|
35384
34891
|
}
|
|
35385
34892
|
|
|
35386
34893
|
var admissionProfileFactory = /*#__PURE__*/Object.freeze({
|
|
35387
34894
|
__proto__: null,
|
|
35388
34895
|
AdmissionProfileFactory: AdmissionProfileFactory,
|
|
35389
|
-
FACTORY_META: FACTORY_META$
|
|
34896
|
+
FACTORY_META: FACTORY_META$O,
|
|
35390
34897
|
default: AdmissionProfileFactory
|
|
35391
34898
|
});
|
|
35392
34899
|
|
|
35393
|
-
const logger$
|
|
34900
|
+
const logger$f = getLogger('naylence.fame.node.admission.direct_admission_client');
|
|
35394
34901
|
class DirectAdmissionClient {
|
|
35395
34902
|
constructor(options) {
|
|
35396
34903
|
this.hasUpstream = true;
|
|
@@ -35415,7 +34922,7 @@ class DirectAdmissionClient {
|
|
|
35415
34922
|
}
|
|
35416
34923
|
}
|
|
35417
34924
|
async hello(systemId, instanceId, requestedLogicals) {
|
|
35418
|
-
logger$
|
|
34925
|
+
logger$f.debug('direct_admission_hello_start', {
|
|
35419
34926
|
providedSystemId: systemId,
|
|
35420
34927
|
instanceId,
|
|
35421
34928
|
requestedLogicals,
|
|
@@ -35423,7 +34930,7 @@ class DirectAdmissionClient {
|
|
|
35423
34930
|
const effectiveSystemId = systemId && systemId.trim().length > 0
|
|
35424
34931
|
? systemId
|
|
35425
34932
|
: await core.generateIdAsync({ mode: 'fingerprint' }).catch(async () => {
|
|
35426
|
-
logger$
|
|
34933
|
+
logger$f.debug('direct_admission_fingerprint_generation_failed', {
|
|
35427
34934
|
reason: 'falling back to random id',
|
|
35428
34935
|
});
|
|
35429
34936
|
return core.generateIdAsync({ mode: 'random' });
|
|
@@ -35445,7 +34952,7 @@ class DirectAdmissionClient {
|
|
|
35445
34952
|
const envelope = core.createFameEnvelope({
|
|
35446
34953
|
frame: welcomeFrame,
|
|
35447
34954
|
});
|
|
35448
|
-
logger$
|
|
34955
|
+
logger$f.debug('direct_admission_hello_success', {
|
|
35449
34956
|
systemId: welcomeFrame.systemId,
|
|
35450
34957
|
instanceId: welcomeFrame.instanceId,
|
|
35451
34958
|
acceptedLogicals: welcomeFrame.acceptedLogicals,
|
|
@@ -35468,7 +34975,7 @@ function cloneGrant(grant) {
|
|
|
35468
34975
|
return JSON.parse(JSON.stringify(grant));
|
|
35469
34976
|
}
|
|
35470
34977
|
|
|
35471
|
-
const FACTORY_META$
|
|
34978
|
+
const FACTORY_META$N = {
|
|
35472
34979
|
base: ADMISSION_CLIENT_FACTORY_BASE_TYPE,
|
|
35473
34980
|
key: 'DirectAdmissionClient',
|
|
35474
34981
|
};
|
|
@@ -35481,7 +34988,7 @@ class DirectAdmissionClientFactory extends AdmissionClientFactory {
|
|
|
35481
34988
|
if (!config) {
|
|
35482
34989
|
throw new Error('DirectAdmissionClient configuration is required');
|
|
35483
34990
|
}
|
|
35484
|
-
const normalized = normalizeConfig$
|
|
34991
|
+
const normalized = normalizeConfig$m(config);
|
|
35485
34992
|
const evaluatedGrants = normalized.connectionGrants.map((grant) => {
|
|
35486
34993
|
const evaluated = ConnectorFactory.evaluateGrant({
|
|
35487
34994
|
...grant,
|
|
@@ -35494,7 +35001,7 @@ class DirectAdmissionClientFactory extends AdmissionClientFactory {
|
|
|
35494
35001
|
});
|
|
35495
35002
|
}
|
|
35496
35003
|
}
|
|
35497
|
-
function normalizeConfig$
|
|
35004
|
+
function normalizeConfig$m(config) {
|
|
35498
35005
|
const source = config;
|
|
35499
35006
|
const connectionGrantsRaw = source.connectionGrants ?? source.connection_grants;
|
|
35500
35007
|
if (!Array.isArray(connectionGrantsRaw) || connectionGrantsRaw.length === 0) {
|
|
@@ -35520,11 +35027,11 @@ function normalizeConfig$l(config) {
|
|
|
35520
35027
|
var directAdmissionClientFactory = /*#__PURE__*/Object.freeze({
|
|
35521
35028
|
__proto__: null,
|
|
35522
35029
|
DirectAdmissionClientFactory: DirectAdmissionClientFactory,
|
|
35523
|
-
FACTORY_META: FACTORY_META$
|
|
35030
|
+
FACTORY_META: FACTORY_META$N,
|
|
35524
35031
|
default: DirectAdmissionClientFactory
|
|
35525
35032
|
});
|
|
35526
35033
|
|
|
35527
|
-
const FACTORY_META$
|
|
35034
|
+
const FACTORY_META$M = {
|
|
35528
35035
|
base: ADMISSION_CLIENT_FACTORY_BASE_TYPE,
|
|
35529
35036
|
key: 'NoopAdmissionClient',
|
|
35530
35037
|
};
|
|
@@ -35536,11 +35043,11 @@ class NoopAdmissionClientFactory extends AdmissionClientFactory {
|
|
|
35536
35043
|
this.priority = 0;
|
|
35537
35044
|
}
|
|
35538
35045
|
async create(config, ...factoryArgs) {
|
|
35539
|
-
const resolved = normalizeConfig$
|
|
35046
|
+
const resolved = normalizeConfig$l(config, factoryArgs);
|
|
35540
35047
|
return new NoopAdmissionClient(resolved);
|
|
35541
35048
|
}
|
|
35542
35049
|
}
|
|
35543
|
-
function normalizeConfig$
|
|
35050
|
+
function normalizeConfig$l(config, factoryArgs) {
|
|
35544
35051
|
const fromArgs = factoryArgs[0] && typeof factoryArgs[0] === 'object'
|
|
35545
35052
|
? factoryArgs[0]
|
|
35546
35053
|
: {};
|
|
@@ -35573,7 +35080,7 @@ function normalizeConfig$k(config, factoryArgs) {
|
|
|
35573
35080
|
|
|
35574
35081
|
var noopAdmissionClientFactory = /*#__PURE__*/Object.freeze({
|
|
35575
35082
|
__proto__: null,
|
|
35576
|
-
FACTORY_META: FACTORY_META$
|
|
35083
|
+
FACTORY_META: FACTORY_META$M,
|
|
35577
35084
|
NoopAdmissionClientFactory: NoopAdmissionClientFactory,
|
|
35578
35085
|
default: NoopAdmissionClientFactory
|
|
35579
35086
|
});
|
|
@@ -35588,7 +35095,7 @@ class NoAuthInjectionStrategy {
|
|
|
35588
35095
|
}
|
|
35589
35096
|
}
|
|
35590
35097
|
|
|
35591
|
-
const FACTORY_META$
|
|
35098
|
+
const FACTORY_META$L = {
|
|
35592
35099
|
base: AUTH_INJECTION_STRATEGY_FACTORY_BASE_TYPE,
|
|
35593
35100
|
key: 'NoAuth',
|
|
35594
35101
|
};
|
|
@@ -35598,11 +35105,11 @@ class NoAuthInjectionStrategyFactory extends AuthInjectionStrategyFactory {
|
|
|
35598
35105
|
this.type = 'NoAuth';
|
|
35599
35106
|
}
|
|
35600
35107
|
async create(config) {
|
|
35601
|
-
const preparedConfig = normalizeConfig$
|
|
35108
|
+
const preparedConfig = normalizeConfig$k(config);
|
|
35602
35109
|
return new NoAuthInjectionStrategy(preparedConfig);
|
|
35603
35110
|
}
|
|
35604
35111
|
}
|
|
35605
|
-
function normalizeConfig$
|
|
35112
|
+
function normalizeConfig$k(config) {
|
|
35606
35113
|
const defaultConfig = { type: 'NoAuth' };
|
|
35607
35114
|
if (!config) {
|
|
35608
35115
|
return defaultConfig;
|
|
@@ -35617,12 +35124,12 @@ function normalizeConfig$j(config) {
|
|
|
35617
35124
|
|
|
35618
35125
|
var noAuthInjectionStrategyFactory = /*#__PURE__*/Object.freeze({
|
|
35619
35126
|
__proto__: null,
|
|
35620
|
-
FACTORY_META: FACTORY_META$
|
|
35127
|
+
FACTORY_META: FACTORY_META$L,
|
|
35621
35128
|
NoAuthInjectionStrategyFactory: NoAuthInjectionStrategyFactory,
|
|
35622
35129
|
default: NoAuthInjectionStrategyFactory
|
|
35623
35130
|
});
|
|
35624
35131
|
|
|
35625
|
-
const logger$
|
|
35132
|
+
const logger$e = getLogger('naylence.fame.node.admission.welcome_service_client');
|
|
35626
35133
|
class WelcomeServiceClient {
|
|
35627
35134
|
constructor(options) {
|
|
35628
35135
|
this.hasUpstream = options.hasUpstream ?? options.has_upstream ?? false;
|
|
@@ -35671,7 +35178,7 @@ class WelcomeServiceClient {
|
|
|
35671
35178
|
'Content-Type': 'application/json',
|
|
35672
35179
|
...authHeaders,
|
|
35673
35180
|
};
|
|
35674
|
-
logger$
|
|
35181
|
+
logger$e.debug('welcome_service_hello_request', {
|
|
35675
35182
|
url: this.url,
|
|
35676
35183
|
systemId,
|
|
35677
35184
|
instanceId,
|
|
@@ -35707,7 +35214,7 @@ class WelcomeServiceClient {
|
|
|
35707
35214
|
parsedEnvelope.frame.type !== 'NodeWelcome') {
|
|
35708
35215
|
throw new Error(`Unexpected frame type '${parsedEnvelope.frame?.type ?? 'unknown'}'`);
|
|
35709
35216
|
}
|
|
35710
|
-
logger$
|
|
35217
|
+
logger$e.debug('welcome_service_hello_success', {
|
|
35711
35218
|
systemId: parsedEnvelope.frame.systemId,
|
|
35712
35219
|
targetSystemId: parsedEnvelope.frame.targetSystemId,
|
|
35713
35220
|
assignedPath: parsedEnvelope.frame.assignedPath,
|
|
@@ -35766,7 +35273,7 @@ function convertKeysToCamelCase(value) {
|
|
|
35766
35273
|
return result;
|
|
35767
35274
|
}
|
|
35768
35275
|
|
|
35769
|
-
const FACTORY_META$
|
|
35276
|
+
const FACTORY_META$K = {
|
|
35770
35277
|
base: ADMISSION_CLIENT_FACTORY_BASE_TYPE,
|
|
35771
35278
|
key: 'WelcomeServiceClient',
|
|
35772
35279
|
};
|
|
@@ -35779,7 +35286,7 @@ class WelcomeServiceClientFactory extends AdmissionClientFactory {
|
|
|
35779
35286
|
if (!config) {
|
|
35780
35287
|
throw new Error('WelcomeServiceClient configuration is required');
|
|
35781
35288
|
}
|
|
35782
|
-
const normalized = normalizeConfig$
|
|
35289
|
+
const normalized = normalizeConfig$j(config);
|
|
35783
35290
|
const clientOptions = {
|
|
35784
35291
|
hasUpstream: !normalized.isRoot,
|
|
35785
35292
|
url: normalized.url,
|
|
@@ -35794,7 +35301,7 @@ class WelcomeServiceClientFactory extends AdmissionClientFactory {
|
|
|
35794
35301
|
return new WelcomeServiceClient(clientOptions);
|
|
35795
35302
|
}
|
|
35796
35303
|
}
|
|
35797
|
-
function normalizeConfig$
|
|
35304
|
+
function normalizeConfig$j(config) {
|
|
35798
35305
|
const source = config;
|
|
35799
35306
|
const urlCandidate = typeof source.url === 'string' ? source.url.trim() : '';
|
|
35800
35307
|
if (!urlCandidate) {
|
|
@@ -35836,7 +35343,7 @@ async function createAuthStrategy(config) {
|
|
|
35836
35343
|
|
|
35837
35344
|
var welcomeServiceClientFactory = /*#__PURE__*/Object.freeze({
|
|
35838
35345
|
__proto__: null,
|
|
35839
|
-
FACTORY_META: FACTORY_META$
|
|
35346
|
+
FACTORY_META: FACTORY_META$K,
|
|
35840
35347
|
WelcomeServiceClientFactory: WelcomeServiceClientFactory,
|
|
35841
35348
|
default: WelcomeServiceClientFactory
|
|
35842
35349
|
});
|
|
@@ -35912,7 +35419,7 @@ const staticNodePlacementConfigSchema = zod.z
|
|
|
35912
35419
|
.min(1, { message: 'targetPhysicalPath cannot be empty' }),
|
|
35913
35420
|
})
|
|
35914
35421
|
.passthrough();
|
|
35915
|
-
function normalizeConfig$
|
|
35422
|
+
function normalizeConfig$i(config) {
|
|
35916
35423
|
const candidate = {
|
|
35917
35424
|
...config,
|
|
35918
35425
|
};
|
|
@@ -35947,14 +35454,14 @@ class StaticNodePlacementStrategyFactory extends NodePlacementStrategyFactory {
|
|
|
35947
35454
|
if (!config) {
|
|
35948
35455
|
throw new Error('StaticNodePlacementStrategy requires configuration');
|
|
35949
35456
|
}
|
|
35950
|
-
const normalized = normalizeConfig$
|
|
35457
|
+
const normalized = normalizeConfig$i(config);
|
|
35951
35458
|
return new StaticNodePlacementStrategy({
|
|
35952
35459
|
targetSystemId: normalized.targetSystemId,
|
|
35953
35460
|
targetPhysicalPath: normalized.targetPhysicalPath,
|
|
35954
35461
|
});
|
|
35955
35462
|
}
|
|
35956
35463
|
}
|
|
35957
|
-
const FACTORY_META$
|
|
35464
|
+
const FACTORY_META$J = {
|
|
35958
35465
|
base: NODE_PLACEMENT_STRATEGY_FACTORY_BASE_TYPE,
|
|
35959
35466
|
key: 'StaticNodePlacementStrategy',
|
|
35960
35467
|
};
|
|
@@ -35964,7 +35471,7 @@ registerNodePlacementStrategyFactory('StaticNodePlacementStrategy', StaticNodePl
|
|
|
35964
35471
|
|
|
35965
35472
|
var staticNodePlacementStrategyFactory = /*#__PURE__*/Object.freeze({
|
|
35966
35473
|
__proto__: null,
|
|
35967
|
-
FACTORY_META: FACTORY_META$
|
|
35474
|
+
FACTORY_META: FACTORY_META$J,
|
|
35968
35475
|
StaticNodePlacementStrategyFactory: StaticNodePlacementStrategyFactory,
|
|
35969
35476
|
default: StaticNodePlacementStrategyFactory
|
|
35970
35477
|
});
|
|
@@ -36123,7 +35630,7 @@ function connectorTypeName(connector) {
|
|
|
36123
35630
|
return typeof connector;
|
|
36124
35631
|
}
|
|
36125
35632
|
|
|
36126
|
-
const FACTORY_META$
|
|
35633
|
+
const FACTORY_META$I = {
|
|
36127
35634
|
base: AUTH_INJECTION_STRATEGY_FACTORY_BASE_TYPE,
|
|
36128
35635
|
key: 'BearerTokenHeaderAuth',
|
|
36129
35636
|
};
|
|
@@ -36133,11 +35640,11 @@ class BearerTokenHeaderAuthInjectionStrategyFactory extends AuthInjectionStrateg
|
|
|
36133
35640
|
this.type = 'BearerTokenHeaderAuth';
|
|
36134
35641
|
}
|
|
36135
35642
|
async create(config) {
|
|
36136
|
-
const normalized = normalizeConfig$
|
|
35643
|
+
const normalized = normalizeConfig$h(config);
|
|
36137
35644
|
return new BearerTokenHeaderAuthInjectionStrategy(normalized);
|
|
36138
35645
|
}
|
|
36139
35646
|
}
|
|
36140
|
-
function normalizeConfig$
|
|
35647
|
+
function normalizeConfig$h(config) {
|
|
36141
35648
|
if (!config) {
|
|
36142
35649
|
throw new Error('BearerTokenHeaderAuthInjectionStrategy requires configuration');
|
|
36143
35650
|
}
|
|
@@ -36164,7 +35671,7 @@ function normalizeConfig$g(config) {
|
|
|
36164
35671
|
var bearerTokenHeaderAuthInjectionStrategyFactory = /*#__PURE__*/Object.freeze({
|
|
36165
35672
|
__proto__: null,
|
|
36166
35673
|
BearerTokenHeaderAuthInjectionStrategyFactory: BearerTokenHeaderAuthInjectionStrategyFactory,
|
|
36167
|
-
FACTORY_META: FACTORY_META$
|
|
35674
|
+
FACTORY_META: FACTORY_META$I,
|
|
36168
35675
|
default: BearerTokenHeaderAuthInjectionStrategyFactory
|
|
36169
35676
|
});
|
|
36170
35677
|
|
|
@@ -36175,7 +35682,7 @@ async function getDefaultAuthorizerModule() {
|
|
|
36175
35682
|
}
|
|
36176
35683
|
return defaultAuthorizerModulePromise;
|
|
36177
35684
|
}
|
|
36178
|
-
function normalizeConfig$
|
|
35685
|
+
function normalizeConfig$g(config) {
|
|
36179
35686
|
if (!config) {
|
|
36180
35687
|
return {};
|
|
36181
35688
|
}
|
|
@@ -36191,7 +35698,7 @@ function normalizeConfig$f(config) {
|
|
|
36191
35698
|
function isTokenVerifier(candidate) {
|
|
36192
35699
|
return Boolean(candidate && typeof candidate.verify === 'function');
|
|
36193
35700
|
}
|
|
36194
|
-
const FACTORY_META$
|
|
35701
|
+
const FACTORY_META$H = {
|
|
36195
35702
|
base: AUTHORIZER_FACTORY_BASE_TYPE,
|
|
36196
35703
|
key: 'DefaultAuthorizer',
|
|
36197
35704
|
};
|
|
@@ -36203,7 +35710,7 @@ class DefaultAuthorizerFactory extends AuthorizerFactory {
|
|
|
36203
35710
|
}
|
|
36204
35711
|
async create(config, ...factoryArgs) {
|
|
36205
35712
|
let tokenVerifier = factoryArgs.find(isTokenVerifier);
|
|
36206
|
-
const normalized = normalizeConfig$
|
|
35713
|
+
const normalized = normalizeConfig$g(config);
|
|
36207
35714
|
if (!tokenVerifier) {
|
|
36208
35715
|
if (!normalized.verifier) {
|
|
36209
35716
|
throw new Error('DefaultAuthorizer requires a verifier configuration or instance');
|
|
@@ -36221,7 +35728,7 @@ class DefaultAuthorizerFactory extends AuthorizerFactory {
|
|
|
36221
35728
|
var defaultAuthorizerFactory = /*#__PURE__*/Object.freeze({
|
|
36222
35729
|
__proto__: null,
|
|
36223
35730
|
DefaultAuthorizerFactory: DefaultAuthorizerFactory,
|
|
36224
|
-
FACTORY_META: FACTORY_META$
|
|
35731
|
+
FACTORY_META: FACTORY_META$H,
|
|
36225
35732
|
default: DefaultAuthorizerFactory
|
|
36226
35733
|
});
|
|
36227
35734
|
|
|
@@ -36232,7 +35739,7 @@ function getJwksJwtTokenVerifierModule() {
|
|
|
36232
35739
|
}
|
|
36233
35740
|
return jwksJwtTokenVerifierModulePromise;
|
|
36234
35741
|
}
|
|
36235
|
-
const FACTORY_META$
|
|
35742
|
+
const FACTORY_META$G = {
|
|
36236
35743
|
base: TOKEN_VERIFIER_FACTORY_BASE_TYPE,
|
|
36237
35744
|
key: 'JWKSJWTTokenVerifier',
|
|
36238
35745
|
};
|
|
@@ -36245,7 +35752,7 @@ class JWKSTokenVerifierFactory extends TokenVerifierFactory {
|
|
|
36245
35752
|
if (!config) {
|
|
36246
35753
|
throw new Error('JWKSJWTTokenVerifier requires configuration');
|
|
36247
35754
|
}
|
|
36248
|
-
const normalized = normalizeConfig$
|
|
35755
|
+
const normalized = normalizeConfig$f(config);
|
|
36249
35756
|
const cacheTtlCandidate = validateCacheTtlSec(normalized.cacheTtlSec);
|
|
36250
35757
|
const cacheTtlSec = typeof cacheTtlCandidate === 'number'
|
|
36251
35758
|
? cacheTtlCandidate
|
|
@@ -36259,7 +35766,7 @@ class JWKSTokenVerifierFactory extends TokenVerifierFactory {
|
|
|
36259
35766
|
});
|
|
36260
35767
|
}
|
|
36261
35768
|
}
|
|
36262
|
-
function normalizeConfig$
|
|
35769
|
+
function normalizeConfig$f(config) {
|
|
36263
35770
|
const source = config;
|
|
36264
35771
|
const issuer = typeof source.issuer === 'string' && source.issuer.trim().length > 0
|
|
36265
35772
|
? source.issuer
|
|
@@ -36294,12 +35801,12 @@ function normalizeConfig$e(config) {
|
|
|
36294
35801
|
|
|
36295
35802
|
var jwksJwtTokenVerifierFactory = /*#__PURE__*/Object.freeze({
|
|
36296
35803
|
__proto__: null,
|
|
36297
|
-
FACTORY_META: FACTORY_META$
|
|
35804
|
+
FACTORY_META: FACTORY_META$G,
|
|
36298
35805
|
JWKSTokenVerifierFactory: JWKSTokenVerifierFactory,
|
|
36299
35806
|
default: JWKSTokenVerifierFactory
|
|
36300
35807
|
});
|
|
36301
35808
|
|
|
36302
|
-
const FACTORY_META$
|
|
35809
|
+
const FACTORY_META$F = {
|
|
36303
35810
|
base: TOKEN_ISSUER_FACTORY_BASE_TYPE,
|
|
36304
35811
|
key: 'JWTTokenIssuer',
|
|
36305
35812
|
};
|
|
@@ -36313,7 +35820,7 @@ class JWTTokenIssuerFactory extends TokenIssuerFactory {
|
|
|
36313
35820
|
if (!config) {
|
|
36314
35821
|
throw new Error('JWTTokenIssuerFactory requires configuration');
|
|
36315
35822
|
}
|
|
36316
|
-
const normalized = normalizeConfig$
|
|
35823
|
+
const normalized = normalizeConfig$e(config);
|
|
36317
35824
|
// Extract crypto provider from factory args
|
|
36318
35825
|
let cryptoProvider1 = null;
|
|
36319
35826
|
for (const arg of factoryArgs) {
|
|
@@ -36370,7 +35877,7 @@ function getJwtTokenIssuerModule() {
|
|
|
36370
35877
|
}
|
|
36371
35878
|
return jwtTokenIssuerModulePromise;
|
|
36372
35879
|
}
|
|
36373
|
-
function normalizeConfig$
|
|
35880
|
+
function normalizeConfig$e(config) {
|
|
36374
35881
|
const source = config;
|
|
36375
35882
|
const issuer = typeof source.issuer === 'string' && source.issuer.trim() !== ''
|
|
36376
35883
|
? source.issuer
|
|
@@ -36496,12 +36003,12 @@ function getProviderKeyId(provider) {
|
|
|
36496
36003
|
|
|
36497
36004
|
var jwtTokenIssuerFactory = /*#__PURE__*/Object.freeze({
|
|
36498
36005
|
__proto__: null,
|
|
36499
|
-
FACTORY_META: FACTORY_META$
|
|
36006
|
+
FACTORY_META: FACTORY_META$F,
|
|
36500
36007
|
JWTTokenIssuerFactory: JWTTokenIssuerFactory,
|
|
36501
36008
|
default: JWTTokenIssuerFactory
|
|
36502
36009
|
});
|
|
36503
36010
|
|
|
36504
|
-
const FACTORY_META$
|
|
36011
|
+
const FACTORY_META$E = {
|
|
36505
36012
|
base: TOKEN_VERIFIER_FACTORY_BASE_TYPE,
|
|
36506
36013
|
key: 'JWTTokenVerifier',
|
|
36507
36014
|
};
|
|
@@ -36515,7 +36022,7 @@ class JWTTokenVerifierFactory extends TokenVerifierFactory {
|
|
|
36515
36022
|
if (!config) {
|
|
36516
36023
|
throw new Error('JWTTokenVerifierFactory requires configuration');
|
|
36517
36024
|
}
|
|
36518
|
-
const normalized = normalizeConfig$
|
|
36025
|
+
const normalized = normalizeConfig$d(config);
|
|
36519
36026
|
const cryptoProvider1 = cryptoProvider ?? null;
|
|
36520
36027
|
let verificationKey;
|
|
36521
36028
|
if (normalized.hmacSecret !== undefined) {
|
|
@@ -36552,7 +36059,7 @@ function getJwtTokenVerifierModule() {
|
|
|
36552
36059
|
}
|
|
36553
36060
|
return jwtTokenVerifierModulePromise;
|
|
36554
36061
|
}
|
|
36555
|
-
function normalizeConfig$
|
|
36062
|
+
function normalizeConfig$d(config) {
|
|
36556
36063
|
const source = config;
|
|
36557
36064
|
const issuer = typeof source.issuer === 'string' && source.issuer.trim() !== ''
|
|
36558
36065
|
? source.issuer
|
|
@@ -36669,7 +36176,7 @@ function getProviderVerificationKey(provider) {
|
|
|
36669
36176
|
|
|
36670
36177
|
var jwtTokenVerifierFactory = /*#__PURE__*/Object.freeze({
|
|
36671
36178
|
__proto__: null,
|
|
36672
|
-
FACTORY_META: FACTORY_META$
|
|
36179
|
+
FACTORY_META: FACTORY_META$E,
|
|
36673
36180
|
JWTTokenVerifierFactory: JWTTokenVerifierFactory,
|
|
36674
36181
|
default: JWTTokenVerifierFactory
|
|
36675
36182
|
});
|
|
@@ -36685,7 +36192,7 @@ class NoneTokenProvider {
|
|
|
36685
36192
|
}
|
|
36686
36193
|
}
|
|
36687
36194
|
|
|
36688
|
-
const FACTORY_META$
|
|
36195
|
+
const FACTORY_META$D = {
|
|
36689
36196
|
base: TOKEN_PROVIDER_FACTORY_BASE_TYPE,
|
|
36690
36197
|
key: 'NoneTokenProvider',
|
|
36691
36198
|
};
|
|
@@ -36702,7 +36209,7 @@ class NoneTokenProviderFactory extends TokenProviderFactory {
|
|
|
36702
36209
|
|
|
36703
36210
|
var noneTokenProviderFactory = /*#__PURE__*/Object.freeze({
|
|
36704
36211
|
__proto__: null,
|
|
36705
|
-
FACTORY_META: FACTORY_META$
|
|
36212
|
+
FACTORY_META: FACTORY_META$D,
|
|
36706
36213
|
NoneTokenProviderFactory: NoneTokenProviderFactory,
|
|
36707
36214
|
default: NoneTokenProviderFactory
|
|
36708
36215
|
});
|
|
@@ -36754,7 +36261,7 @@ class NoopAuthorizer {
|
|
|
36754
36261
|
}
|
|
36755
36262
|
}
|
|
36756
36263
|
|
|
36757
|
-
const FACTORY_META$
|
|
36264
|
+
const FACTORY_META$C = {
|
|
36758
36265
|
base: AUTHORIZER_FACTORY_BASE_TYPE,
|
|
36759
36266
|
key: 'NoopAuthorizer',
|
|
36760
36267
|
};
|
|
@@ -36770,7 +36277,7 @@ class NoopAuthorizerFactory extends AuthorizerFactory {
|
|
|
36770
36277
|
|
|
36771
36278
|
var noopAuthorizerFactory = /*#__PURE__*/Object.freeze({
|
|
36772
36279
|
__proto__: null,
|
|
36773
|
-
FACTORY_META: FACTORY_META$
|
|
36280
|
+
FACTORY_META: FACTORY_META$C,
|
|
36774
36281
|
NoopAuthorizerFactory: NoopAuthorizerFactory,
|
|
36775
36282
|
default: NoopAuthorizerFactory
|
|
36776
36283
|
});
|
|
@@ -36784,7 +36291,7 @@ class NoopTokenIssuer {
|
|
|
36784
36291
|
}
|
|
36785
36292
|
}
|
|
36786
36293
|
|
|
36787
|
-
const FACTORY_META$
|
|
36294
|
+
const FACTORY_META$B = {
|
|
36788
36295
|
base: TOKEN_ISSUER_FACTORY_BASE_TYPE,
|
|
36789
36296
|
key: 'NoopTokenIssuer',
|
|
36790
36297
|
};
|
|
@@ -36800,7 +36307,7 @@ class NoopTokenIssuerFactory extends TokenIssuerFactory {
|
|
|
36800
36307
|
|
|
36801
36308
|
var noopTokenIssuerFactory = /*#__PURE__*/Object.freeze({
|
|
36802
36309
|
__proto__: null,
|
|
36803
|
-
FACTORY_META: FACTORY_META$
|
|
36310
|
+
FACTORY_META: FACTORY_META$B,
|
|
36804
36311
|
NoopTokenIssuerFactory: NoopTokenIssuerFactory,
|
|
36805
36312
|
default: NoopTokenIssuerFactory
|
|
36806
36313
|
});
|
|
@@ -36822,7 +36329,7 @@ class NoopTokenVerifier {
|
|
|
36822
36329
|
}
|
|
36823
36330
|
}
|
|
36824
36331
|
|
|
36825
|
-
const FACTORY_META$
|
|
36332
|
+
const FACTORY_META$A = {
|
|
36826
36333
|
base: TOKEN_VERIFIER_FACTORY_BASE_TYPE,
|
|
36827
36334
|
key: 'NoopTokenVerifier',
|
|
36828
36335
|
};
|
|
@@ -36838,12 +36345,12 @@ class NoopTokenVerifierFactory extends TokenVerifierFactory {
|
|
|
36838
36345
|
|
|
36839
36346
|
var noopTokenVerifierFactory = /*#__PURE__*/Object.freeze({
|
|
36840
36347
|
__proto__: null,
|
|
36841
|
-
FACTORY_META: FACTORY_META$
|
|
36348
|
+
FACTORY_META: FACTORY_META$A,
|
|
36842
36349
|
NoopTokenVerifierFactory: NoopTokenVerifierFactory,
|
|
36843
36350
|
default: NoopTokenVerifierFactory
|
|
36844
36351
|
});
|
|
36845
36352
|
|
|
36846
|
-
const logger$
|
|
36353
|
+
const logger$d = getLogger('naylence.fame.security.auth.oauth2_authorizer_factory');
|
|
36847
36354
|
let oauth2AuthorizerModulePromise = null;
|
|
36848
36355
|
function getOAuth2AuthorizerModule() {
|
|
36849
36356
|
if (!oauth2AuthorizerModulePromise) {
|
|
@@ -36851,7 +36358,7 @@ function getOAuth2AuthorizerModule() {
|
|
|
36851
36358
|
}
|
|
36852
36359
|
return oauth2AuthorizerModulePromise;
|
|
36853
36360
|
}
|
|
36854
|
-
const FACTORY_META$
|
|
36361
|
+
const FACTORY_META$z = {
|
|
36855
36362
|
base: AUTHORIZER_FACTORY_BASE_TYPE,
|
|
36856
36363
|
key: 'OAuth2Authorizer',
|
|
36857
36364
|
};
|
|
@@ -36864,18 +36371,18 @@ class OAuth2AuthorizerFactory extends AuthorizerFactory {
|
|
|
36864
36371
|
if (!config) {
|
|
36865
36372
|
throw new Error('OAuth2Authorizer requires configuration');
|
|
36866
36373
|
}
|
|
36867
|
-
const normalized = normalizeConfig$
|
|
36374
|
+
const normalized = normalizeConfig$c(config);
|
|
36868
36375
|
const tokenVerifier = await TokenVerifierFactory.createTokenVerifier(normalized.tokenVerifierConfig);
|
|
36869
36376
|
let tokenIssuer;
|
|
36870
36377
|
if (normalized.tokenIssuerConfig) {
|
|
36871
36378
|
try {
|
|
36872
36379
|
tokenIssuer = await TokenIssuerFactory.createTokenIssuer(normalized.tokenIssuerConfig);
|
|
36873
|
-
logger$
|
|
36380
|
+
logger$d.debug('token_issuer_created_for_reverse_auth', {
|
|
36874
36381
|
issuer_type: normalized.tokenIssuerConfig.type,
|
|
36875
36382
|
});
|
|
36876
36383
|
}
|
|
36877
36384
|
catch (error) {
|
|
36878
|
-
logger$
|
|
36385
|
+
logger$d.warning('failed_to_create_token_issuer_for_reverse_auth', {
|
|
36879
36386
|
error: error instanceof Error ? error.message : String(error),
|
|
36880
36387
|
issuer_config: normalized.tokenIssuerConfig,
|
|
36881
36388
|
});
|
|
@@ -36899,7 +36406,7 @@ class OAuth2AuthorizerFactory extends AuthorizerFactory {
|
|
|
36899
36406
|
return new OAuth2Authorizer(authorizerOptions);
|
|
36900
36407
|
}
|
|
36901
36408
|
}
|
|
36902
|
-
function normalizeConfig$
|
|
36409
|
+
function normalizeConfig$c(config) {
|
|
36903
36410
|
const source = config;
|
|
36904
36411
|
const issuer = typeof source.issuer === 'string' && source.issuer.trim().length > 0
|
|
36905
36412
|
? source.issuer.trim()
|
|
@@ -36996,7 +36503,7 @@ function normalizeTokenVerifierConfig({ config, issuer, jwksUrl, algorithm, }) {
|
|
|
36996
36503
|
|
|
36997
36504
|
var oauth2AuthorizerFactory = /*#__PURE__*/Object.freeze({
|
|
36998
36505
|
__proto__: null,
|
|
36999
|
-
FACTORY_META: FACTORY_META$
|
|
36506
|
+
FACTORY_META: FACTORY_META$z,
|
|
37000
36507
|
OAuth2AuthorizerFactory: OAuth2AuthorizerFactory,
|
|
37001
36508
|
default: OAuth2AuthorizerFactory
|
|
37002
36509
|
});
|
|
@@ -37008,7 +36515,7 @@ async function getOAuth2ClientCredentialsTokenProviderModule() {
|
|
|
37008
36515
|
}
|
|
37009
36516
|
return oauth2ClientCredentialsTokenProviderModulePromise;
|
|
37010
36517
|
}
|
|
37011
|
-
function normalizeConfig$
|
|
36518
|
+
function normalizeConfig$b(config) {
|
|
37012
36519
|
if (!config) {
|
|
37013
36520
|
throw new Error('OAuth2ClientCredentialsTokenProvider requires configuration');
|
|
37014
36521
|
}
|
|
@@ -37036,7 +36543,7 @@ function normalizeConfig$a(config) {
|
|
|
37036
36543
|
}
|
|
37037
36544
|
return normalized;
|
|
37038
36545
|
}
|
|
37039
|
-
const FACTORY_META$
|
|
36546
|
+
const FACTORY_META$y = {
|
|
37040
36547
|
base: TOKEN_PROVIDER_FACTORY_BASE_TYPE,
|
|
37041
36548
|
key: 'OAuth2ClientCredentialsTokenProvider',
|
|
37042
36549
|
};
|
|
@@ -37046,7 +36553,7 @@ class OAuth2ClientCredentialsTokenProviderFactory extends TokenProviderFactory {
|
|
|
37046
36553
|
this.type = 'OAuth2ClientCredentialsTokenProvider';
|
|
37047
36554
|
}
|
|
37048
36555
|
async create(config) {
|
|
37049
|
-
const normalized = normalizeConfig$
|
|
36556
|
+
const normalized = normalizeConfig$b(config);
|
|
37050
36557
|
const [clientIdProvider, clientSecretProvider] = await Promise.all([
|
|
37051
36558
|
CredentialProviderFactory.createCredentialProvider(normalized.clientIdConfig),
|
|
37052
36559
|
CredentialProviderFactory.createCredentialProvider(normalized.clientSecretConfig),
|
|
@@ -37067,7 +36574,7 @@ class OAuth2ClientCredentialsTokenProviderFactory extends TokenProviderFactory {
|
|
|
37067
36574
|
|
|
37068
36575
|
var oauth2ClientCredentialsTokenProviderFactory = /*#__PURE__*/Object.freeze({
|
|
37069
36576
|
__proto__: null,
|
|
37070
|
-
FACTORY_META: FACTORY_META$
|
|
36577
|
+
FACTORY_META: FACTORY_META$y,
|
|
37071
36578
|
OAuth2ClientCredentialsTokenProviderFactory: OAuth2ClientCredentialsTokenProviderFactory,
|
|
37072
36579
|
default: OAuth2ClientCredentialsTokenProviderFactory
|
|
37073
36580
|
});
|
|
@@ -37100,7 +36607,7 @@ function normalizeScopes$1(value) {
|
|
|
37100
36607
|
}
|
|
37101
36608
|
return [];
|
|
37102
36609
|
}
|
|
37103
|
-
function normalizeConfig$
|
|
36610
|
+
function normalizeConfig$a(config) {
|
|
37104
36611
|
if (!config) {
|
|
37105
36612
|
throw new Error('OAuth2PkceTokenProvider requires configuration');
|
|
37106
36613
|
}
|
|
@@ -37149,7 +36656,7 @@ function normalizeConfig$9(config) {
|
|
|
37149
36656
|
}
|
|
37150
36657
|
return normalized;
|
|
37151
36658
|
}
|
|
37152
|
-
const FACTORY_META$
|
|
36659
|
+
const FACTORY_META$x = {
|
|
37153
36660
|
base: TOKEN_PROVIDER_FACTORY_BASE_TYPE,
|
|
37154
36661
|
key: 'OAuth2PkceTokenProvider',
|
|
37155
36662
|
};
|
|
@@ -37159,7 +36666,7 @@ class OAuth2PkceTokenProviderFactory extends TokenProviderFactory {
|
|
|
37159
36666
|
this.type = 'OAuth2PkceTokenProvider';
|
|
37160
36667
|
}
|
|
37161
36668
|
async create(config) {
|
|
37162
|
-
const normalized = normalizeConfig$
|
|
36669
|
+
const normalized = normalizeConfig$a(config);
|
|
37163
36670
|
const [usernameProvider, clientSecretProvider] = await Promise.all([
|
|
37164
36671
|
normalized.usernameConfig
|
|
37165
36672
|
? CredentialProviderFactory.createCredentialProvider(normalized.usernameConfig)
|
|
@@ -37204,7 +36711,7 @@ class OAuth2PkceTokenProviderFactory extends TokenProviderFactory {
|
|
|
37204
36711
|
|
|
37205
36712
|
var oauth2PkceTokenProviderFactory = /*#__PURE__*/Object.freeze({
|
|
37206
36713
|
__proto__: null,
|
|
37207
|
-
FACTORY_META: FACTORY_META$
|
|
36714
|
+
FACTORY_META: FACTORY_META$x,
|
|
37208
36715
|
OAuth2PkceTokenProviderFactory: OAuth2PkceTokenProviderFactory,
|
|
37209
36716
|
default: OAuth2PkceTokenProviderFactory
|
|
37210
36717
|
});
|
|
@@ -37254,7 +36761,7 @@ class QueryParamAuthInjectionStrategy {
|
|
|
37254
36761
|
}
|
|
37255
36762
|
}
|
|
37256
36763
|
|
|
37257
|
-
const FACTORY_META$
|
|
36764
|
+
const FACTORY_META$w = {
|
|
37258
36765
|
base: AUTH_INJECTION_STRATEGY_FACTORY_BASE_TYPE,
|
|
37259
36766
|
key: 'QueryParamAuth',
|
|
37260
36767
|
};
|
|
@@ -37264,11 +36771,11 @@ class QueryParamAuthInjectionStrategyFactory extends AuthInjectionStrategyFactor
|
|
|
37264
36771
|
this.type = 'QueryParamAuth';
|
|
37265
36772
|
}
|
|
37266
36773
|
async create(config) {
|
|
37267
|
-
const normalized = normalizeConfig$
|
|
36774
|
+
const normalized = normalizeConfig$9(config);
|
|
37268
36775
|
return new QueryParamAuthInjectionStrategy(normalized);
|
|
37269
36776
|
}
|
|
37270
36777
|
}
|
|
37271
|
-
function normalizeConfig$
|
|
36778
|
+
function normalizeConfig$9(config) {
|
|
37272
36779
|
if (!config) {
|
|
37273
36780
|
throw new Error('QueryParamAuthInjectionStrategy requires configuration');
|
|
37274
36781
|
}
|
|
@@ -37294,7 +36801,7 @@ function normalizeConfig$8(config) {
|
|
|
37294
36801
|
|
|
37295
36802
|
var queryParamAuthInjectionStrategyFactory = /*#__PURE__*/Object.freeze({
|
|
37296
36803
|
__proto__: null,
|
|
37297
|
-
FACTORY_META: FACTORY_META$
|
|
36804
|
+
FACTORY_META: FACTORY_META$w,
|
|
37298
36805
|
QueryParamAuthInjectionStrategyFactory: QueryParamAuthInjectionStrategyFactory,
|
|
37299
36806
|
default: QueryParamAuthInjectionStrategyFactory
|
|
37300
36807
|
});
|
|
@@ -37306,7 +36813,7 @@ async function getSharedSecretAuthorizerModule() {
|
|
|
37306
36813
|
}
|
|
37307
36814
|
return sharedSecretAuthorizerModulePromise;
|
|
37308
36815
|
}
|
|
37309
|
-
function normalizeConfig$
|
|
36816
|
+
function normalizeConfig$8(config) {
|
|
37310
36817
|
if (!config) {
|
|
37311
36818
|
throw new Error('SharedSecretAuthorizer requires configuration');
|
|
37312
36819
|
}
|
|
@@ -37330,7 +36837,7 @@ function normalizeConfig$7(config) {
|
|
|
37330
36837
|
secretConfig: normalizeSecretSource(secretSource),
|
|
37331
36838
|
};
|
|
37332
36839
|
}
|
|
37333
|
-
const FACTORY_META$
|
|
36840
|
+
const FACTORY_META$v = {
|
|
37334
36841
|
base: AUTHORIZER_FACTORY_BASE_TYPE,
|
|
37335
36842
|
key: 'SharedSecretAuthorizer',
|
|
37336
36843
|
};
|
|
@@ -37340,7 +36847,7 @@ class SharedSecretAuthorizerFactory extends AuthorizerFactory {
|
|
|
37340
36847
|
this.type = 'SharedSecretAuthorizer';
|
|
37341
36848
|
}
|
|
37342
36849
|
async create(config) {
|
|
37343
|
-
const normalized = normalizeConfig$
|
|
36850
|
+
const normalized = normalizeConfig$8(config);
|
|
37344
36851
|
const credentialProvider = await CredentialProviderFactory.createCredentialProvider(normalized.secretConfig);
|
|
37345
36852
|
const { SharedSecretAuthorizer } = await getSharedSecretAuthorizerModule();
|
|
37346
36853
|
return new SharedSecretAuthorizer(credentialProvider);
|
|
@@ -37349,7 +36856,7 @@ class SharedSecretAuthorizerFactory extends AuthorizerFactory {
|
|
|
37349
36856
|
|
|
37350
36857
|
var sharedSecretAuthorizerFactory = /*#__PURE__*/Object.freeze({
|
|
37351
36858
|
__proto__: null,
|
|
37352
|
-
FACTORY_META: FACTORY_META$
|
|
36859
|
+
FACTORY_META: FACTORY_META$v,
|
|
37353
36860
|
SharedSecretAuthorizerFactory: SharedSecretAuthorizerFactory,
|
|
37354
36861
|
default: SharedSecretAuthorizerFactory
|
|
37355
36862
|
});
|
|
@@ -37361,7 +36868,7 @@ async function getSharedSecretTokenProviderModule() {
|
|
|
37361
36868
|
}
|
|
37362
36869
|
return sharedSecretTokenProviderModulePromise;
|
|
37363
36870
|
}
|
|
37364
|
-
function normalizeConfig$
|
|
36871
|
+
function normalizeConfig$7(config) {
|
|
37365
36872
|
if (!config) {
|
|
37366
36873
|
throw new Error('SharedSecretTokenProvider requires configuration');
|
|
37367
36874
|
}
|
|
@@ -37385,7 +36892,7 @@ function normalizeConfig$6(config) {
|
|
|
37385
36892
|
secretConfig: normalizeSecretSource(secretSource),
|
|
37386
36893
|
};
|
|
37387
36894
|
}
|
|
37388
|
-
const FACTORY_META$
|
|
36895
|
+
const FACTORY_META$u = {
|
|
37389
36896
|
base: TOKEN_PROVIDER_FACTORY_BASE_TYPE,
|
|
37390
36897
|
key: 'SharedSecretTokenProvider',
|
|
37391
36898
|
};
|
|
@@ -37395,7 +36902,7 @@ class SharedSecretTokenProviderFactory extends TokenProviderFactory {
|
|
|
37395
36902
|
this.type = 'SharedSecretTokenProvider';
|
|
37396
36903
|
}
|
|
37397
36904
|
async create(config) {
|
|
37398
|
-
const normalized = normalizeConfig$
|
|
36905
|
+
const normalized = normalizeConfig$7(config);
|
|
37399
36906
|
const credentialProvider = await CredentialProviderFactory.createCredentialProvider(normalized.secretConfig);
|
|
37400
36907
|
const { SharedSecretTokenProvider } = await getSharedSecretTokenProviderModule();
|
|
37401
36908
|
return new SharedSecretTokenProvider(credentialProvider);
|
|
@@ -37404,7 +36911,7 @@ class SharedSecretTokenProviderFactory extends TokenProviderFactory {
|
|
|
37404
36911
|
|
|
37405
36912
|
var sharedSecretTokenProviderFactory = /*#__PURE__*/Object.freeze({
|
|
37406
36913
|
__proto__: null,
|
|
37407
|
-
FACTORY_META: FACTORY_META$
|
|
36914
|
+
FACTORY_META: FACTORY_META$u,
|
|
37408
36915
|
SharedSecretTokenProviderFactory: SharedSecretTokenProviderFactory,
|
|
37409
36916
|
default: SharedSecretTokenProviderFactory
|
|
37410
36917
|
});
|
|
@@ -37416,7 +36923,7 @@ async function getSharedSecretTokenVerifierModule() {
|
|
|
37416
36923
|
}
|
|
37417
36924
|
return sharedSecretTokenVerifierModulePromise;
|
|
37418
36925
|
}
|
|
37419
|
-
function normalizeConfig$
|
|
36926
|
+
function normalizeConfig$6(config) {
|
|
37420
36927
|
const candidate = (config ?? {});
|
|
37421
36928
|
const record = candidate;
|
|
37422
36929
|
let secretSource = candidate.secret;
|
|
@@ -37448,7 +36955,7 @@ function normalizeConfig$5(config) {
|
|
|
37448
36955
|
}
|
|
37449
36956
|
return normalized;
|
|
37450
36957
|
}
|
|
37451
|
-
const FACTORY_META$
|
|
36958
|
+
const FACTORY_META$t = {
|
|
37452
36959
|
base: TOKEN_VERIFIER_FACTORY_BASE_TYPE,
|
|
37453
36960
|
key: 'SharedSecretTokenVerifier',
|
|
37454
36961
|
};
|
|
@@ -37458,7 +36965,7 @@ class SharedSecretTokenVerifierFactory extends TokenVerifierFactory {
|
|
|
37458
36965
|
this.type = 'SharedSecretTokenVerifier';
|
|
37459
36966
|
}
|
|
37460
36967
|
async create(config) {
|
|
37461
|
-
const normalized = normalizeConfig$
|
|
36968
|
+
const normalized = normalizeConfig$6(config);
|
|
37462
36969
|
const credentialProvider = (await CredentialProviderFactory.createCredentialProvider(normalized.secretConfig));
|
|
37463
36970
|
const options = {
|
|
37464
36971
|
credentialProvider,
|
|
@@ -37473,7 +36980,7 @@ class SharedSecretTokenVerifierFactory extends TokenVerifierFactory {
|
|
|
37473
36980
|
|
|
37474
36981
|
var sharedSecretTokenVerifierFactory = /*#__PURE__*/Object.freeze({
|
|
37475
36982
|
__proto__: null,
|
|
37476
|
-
FACTORY_META: FACTORY_META$
|
|
36983
|
+
FACTORY_META: FACTORY_META$t,
|
|
37477
36984
|
SharedSecretTokenVerifierFactory: SharedSecretTokenVerifierFactory,
|
|
37478
36985
|
default: SharedSecretTokenVerifierFactory
|
|
37479
36986
|
});
|
|
@@ -37563,7 +37070,7 @@ function normalizeOptions$8(input) {
|
|
|
37563
37070
|
};
|
|
37564
37071
|
}
|
|
37565
37072
|
|
|
37566
|
-
function normalizeConfig$
|
|
37073
|
+
function normalizeConfig$5(config) {
|
|
37567
37074
|
if (!config) {
|
|
37568
37075
|
throw new Error('StaticTokenProvider requires configuration');
|
|
37569
37076
|
}
|
|
@@ -37588,7 +37095,7 @@ function normalizeConfig$4(config) {
|
|
|
37588
37095
|
}
|
|
37589
37096
|
return options;
|
|
37590
37097
|
}
|
|
37591
|
-
const FACTORY_META$
|
|
37098
|
+
const FACTORY_META$s = {
|
|
37592
37099
|
base: TOKEN_PROVIDER_FACTORY_BASE_TYPE,
|
|
37593
37100
|
key: 'StaticTokenProvider',
|
|
37594
37101
|
};
|
|
@@ -37598,14 +37105,14 @@ class StaticTokenProviderFactory extends TokenProviderFactory {
|
|
|
37598
37105
|
this.type = 'StaticTokenProvider';
|
|
37599
37106
|
}
|
|
37600
37107
|
async create(config) {
|
|
37601
|
-
const options = normalizeConfig$
|
|
37108
|
+
const options = normalizeConfig$5(config);
|
|
37602
37109
|
return new StaticTokenProvider(options);
|
|
37603
37110
|
}
|
|
37604
37111
|
}
|
|
37605
37112
|
|
|
37606
37113
|
var staticTokenProviderFactory = /*#__PURE__*/Object.freeze({
|
|
37607
37114
|
__proto__: null,
|
|
37608
|
-
FACTORY_META: FACTORY_META$
|
|
37115
|
+
FACTORY_META: FACTORY_META$s,
|
|
37609
37116
|
StaticTokenProviderFactory: StaticTokenProviderFactory,
|
|
37610
37117
|
default: StaticTokenProviderFactory
|
|
37611
37118
|
});
|
|
@@ -37656,7 +37163,7 @@ class WebSocketSubprotocolAuthInjectionStrategy {
|
|
|
37656
37163
|
}
|
|
37657
37164
|
}
|
|
37658
37165
|
|
|
37659
|
-
const FACTORY_META$
|
|
37166
|
+
const FACTORY_META$r = {
|
|
37660
37167
|
base: AUTH_INJECTION_STRATEGY_FACTORY_BASE_TYPE,
|
|
37661
37168
|
key: 'WebSocketSubprotocolAuth',
|
|
37662
37169
|
};
|
|
@@ -37666,11 +37173,11 @@ class WebSocketSubprotocolAuthInjectionStrategyFactory extends AuthInjectionStra
|
|
|
37666
37173
|
this.type = 'WebSocketSubprotocolAuth';
|
|
37667
37174
|
}
|
|
37668
37175
|
async create(config) {
|
|
37669
|
-
const normalized = normalizeConfig$
|
|
37176
|
+
const normalized = normalizeConfig$4(config);
|
|
37670
37177
|
return new WebSocketSubprotocolAuthInjectionStrategy(normalized);
|
|
37671
37178
|
}
|
|
37672
37179
|
}
|
|
37673
|
-
function normalizeConfig$
|
|
37180
|
+
function normalizeConfig$4(config) {
|
|
37674
37181
|
if (!config) {
|
|
37675
37182
|
throw new Error('WebSocketSubprotocolAuthInjectionStrategy requires configuration');
|
|
37676
37183
|
}
|
|
@@ -37698,7 +37205,7 @@ function normalizeConfig$3(config) {
|
|
|
37698
37205
|
|
|
37699
37206
|
var websocketSubprotocolAuthInjectionStrategyFactory = /*#__PURE__*/Object.freeze({
|
|
37700
37207
|
__proto__: null,
|
|
37701
|
-
FACTORY_META: FACTORY_META$
|
|
37208
|
+
FACTORY_META: FACTORY_META$r,
|
|
37702
37209
|
WebSocketSubprotocolAuthInjectionStrategyFactory: WebSocketSubprotocolAuthInjectionStrategyFactory,
|
|
37703
37210
|
default: WebSocketSubprotocolAuthInjectionStrategyFactory
|
|
37704
37211
|
});
|
|
@@ -37746,7 +37253,7 @@ class DevFixedKeyCredentialProviderFactory extends CredentialProviderFactory {
|
|
|
37746
37253
|
throw new Error('DevFixedKeyCredentialProvider requires keyHex or keyBase64');
|
|
37747
37254
|
}
|
|
37748
37255
|
}
|
|
37749
|
-
const FACTORY_META$
|
|
37256
|
+
const FACTORY_META$q = {
|
|
37750
37257
|
base: CREDENTIAL_PROVIDER_FACTORY_BASE_TYPE,
|
|
37751
37258
|
key: 'DevFixedKeyCredentialProvider',
|
|
37752
37259
|
};
|
|
@@ -37754,7 +37261,7 @@ const FACTORY_META$n = {
|
|
|
37754
37261
|
var devFixedKeyCredentialProviderFactory = /*#__PURE__*/Object.freeze({
|
|
37755
37262
|
__proto__: null,
|
|
37756
37263
|
DevFixedKeyCredentialProviderFactory: DevFixedKeyCredentialProviderFactory,
|
|
37757
|
-
FACTORY_META: FACTORY_META$
|
|
37264
|
+
FACTORY_META: FACTORY_META$q,
|
|
37758
37265
|
default: DevFixedKeyCredentialProviderFactory,
|
|
37759
37266
|
normalizeDevFixedConfig: normalizeDevFixedConfig
|
|
37760
37267
|
});
|
|
@@ -37770,14 +37277,14 @@ class NoneCredentialProviderFactory extends CredentialProviderFactory {
|
|
|
37770
37277
|
return new NoneCredentialProvider();
|
|
37771
37278
|
}
|
|
37772
37279
|
}
|
|
37773
|
-
const FACTORY_META$
|
|
37280
|
+
const FACTORY_META$p = {
|
|
37774
37281
|
base: CREDENTIAL_PROVIDER_FACTORY_BASE_TYPE,
|
|
37775
37282
|
key: 'NoneCredentialProvider',
|
|
37776
37283
|
};
|
|
37777
37284
|
|
|
37778
37285
|
var noneCredentialProviderFactory = /*#__PURE__*/Object.freeze({
|
|
37779
37286
|
__proto__: null,
|
|
37780
|
-
FACTORY_META: FACTORY_META$
|
|
37287
|
+
FACTORY_META: FACTORY_META$p,
|
|
37781
37288
|
NoneCredentialProviderFactory: NoneCredentialProviderFactory,
|
|
37782
37289
|
default: NoneCredentialProviderFactory
|
|
37783
37290
|
});
|
|
@@ -37815,20 +37322,20 @@ class SessionKeyCredentialProviderFactory extends CredentialProviderFactory {
|
|
|
37815
37322
|
return new SessionKeyCredentialProvider(resolved.length);
|
|
37816
37323
|
}
|
|
37817
37324
|
}
|
|
37818
|
-
const FACTORY_META$
|
|
37325
|
+
const FACTORY_META$o = {
|
|
37819
37326
|
base: CREDENTIAL_PROVIDER_FACTORY_BASE_TYPE,
|
|
37820
37327
|
key: 'SessionKeyCredentialProvider',
|
|
37821
37328
|
};
|
|
37822
37329
|
|
|
37823
37330
|
var sessionKeyCredentialProviderFactory = /*#__PURE__*/Object.freeze({
|
|
37824
37331
|
__proto__: null,
|
|
37825
|
-
FACTORY_META: FACTORY_META$
|
|
37332
|
+
FACTORY_META: FACTORY_META$o,
|
|
37826
37333
|
SessionKeyCredentialProviderFactory: SessionKeyCredentialProviderFactory,
|
|
37827
37334
|
default: SessionKeyCredentialProviderFactory,
|
|
37828
37335
|
normalizeSessionKeyConfig: normalizeSessionKeyConfig
|
|
37829
37336
|
});
|
|
37830
37337
|
|
|
37831
|
-
const logger$
|
|
37338
|
+
const logger$c = getLogger('naylence.fame.security.default_security_manager_factory');
|
|
37832
37339
|
function normalizeDefaultSecurityManagerConfig(config) {
|
|
37833
37340
|
if (!config) {
|
|
37834
37341
|
return null;
|
|
@@ -37863,7 +37370,7 @@ function normalizeDefaultSecurityManagerConfig(config) {
|
|
|
37863
37370
|
ensureAlias('trustStoreProvider', 'trust_store_provider');
|
|
37864
37371
|
return normalized;
|
|
37865
37372
|
}
|
|
37866
|
-
const FACTORY_META$
|
|
37373
|
+
const FACTORY_META$n = {
|
|
37867
37374
|
base: SECURITY_MANAGER_FACTORY_BASE_TYPE,
|
|
37868
37375
|
key: 'DefaultSecurityManager',
|
|
37869
37376
|
};
|
|
@@ -37996,7 +37503,7 @@ class DefaultSecurityManagerFactory extends SecurityManagerFactory {
|
|
|
37996
37503
|
return await KeyStoreFactory.createKeyStore(value, createOptions ?? undefined);
|
|
37997
37504
|
}
|
|
37998
37505
|
catch (error) {
|
|
37999
|
-
logger$
|
|
37506
|
+
logger$c.error('failed_to_create_key_store_from_config', {
|
|
38000
37507
|
error: error instanceof Error ? error.message : String(error),
|
|
38001
37508
|
});
|
|
38002
37509
|
return null;
|
|
@@ -38032,7 +37539,7 @@ class DefaultSecurityManagerFactory extends SecurityManagerFactory {
|
|
|
38032
37539
|
return null;
|
|
38033
37540
|
}
|
|
38034
37541
|
const cryptoProvider = cryptoProviderOverride ?? null;
|
|
38035
|
-
logger$
|
|
37542
|
+
logger$c.debug('auto_create_envelope_signer', {
|
|
38036
37543
|
has_crypto_override: Boolean(cryptoProviderOverride),
|
|
38037
37544
|
override_constructor: cryptoProviderOverride
|
|
38038
37545
|
? (cryptoProviderOverride.constructor?.name ?? 'unknown')
|
|
@@ -38053,7 +37560,7 @@ class DefaultSecurityManagerFactory extends SecurityManagerFactory {
|
|
|
38053
37560
|
});
|
|
38054
37561
|
}
|
|
38055
37562
|
catch (error) {
|
|
38056
|
-
logger$
|
|
37563
|
+
logger$c.error('failed_to_auto_create_envelope_signer', {
|
|
38057
37564
|
error: error instanceof Error ? error.message : String(error),
|
|
38058
37565
|
exc_info: true,
|
|
38059
37566
|
});
|
|
@@ -38088,7 +37595,7 @@ class DefaultSecurityManagerFactory extends SecurityManagerFactory {
|
|
|
38088
37595
|
});
|
|
38089
37596
|
}
|
|
38090
37597
|
catch (error) {
|
|
38091
|
-
logger$
|
|
37598
|
+
logger$c.error('failed_to_auto_create_envelope_verifier', {
|
|
38092
37599
|
error: error instanceof Error ? error.message : String(error),
|
|
38093
37600
|
exc_info: true,
|
|
38094
37601
|
});
|
|
@@ -38100,7 +37607,7 @@ class DefaultSecurityManagerFactory extends SecurityManagerFactory {
|
|
|
38100
37607
|
if (encryptionConfig &&
|
|
38101
37608
|
DefaultSecurityManagerFactory.isConfigLike(encryptionConfig)) {
|
|
38102
37609
|
if (!keyManager) {
|
|
38103
|
-
logger$
|
|
37610
|
+
logger$c.warning('encryption_manager_config_requires_key_manager');
|
|
38104
37611
|
return { encryptionManager: null, secureChannelManager };
|
|
38105
37612
|
}
|
|
38106
37613
|
const manager = await EncryptionManagerFactory.createEncryptionManager(encryptionConfig, {
|
|
@@ -38137,7 +37644,7 @@ class DefaultSecurityManagerFactory extends SecurityManagerFactory {
|
|
|
38137
37644
|
return { encryptionManager: manager, secureChannelManager };
|
|
38138
37645
|
}
|
|
38139
37646
|
catch (error) {
|
|
38140
|
-
logger$
|
|
37647
|
+
logger$c.error('failed_to_auto_create_encryption_manager', {
|
|
38141
37648
|
error: error instanceof Error ? error.message : String(error),
|
|
38142
37649
|
exc_info: true,
|
|
38143
37650
|
});
|
|
@@ -38180,7 +37687,7 @@ class DefaultSecurityManagerFactory extends SecurityManagerFactory {
|
|
|
38180
37687
|
});
|
|
38181
37688
|
}
|
|
38182
37689
|
catch (error) {
|
|
38183
|
-
logger$
|
|
37690
|
+
logger$c.error('failed_to_auto_create_key_manager', {
|
|
38184
37691
|
error: error instanceof Error ? error.message : String(error),
|
|
38185
37692
|
exc_info: true,
|
|
38186
37693
|
});
|
|
@@ -38229,7 +37736,7 @@ class DefaultSecurityManagerFactory extends SecurityManagerFactory {
|
|
|
38229
37736
|
})) ?? null);
|
|
38230
37737
|
}
|
|
38231
37738
|
catch (error) {
|
|
38232
|
-
logger$
|
|
37739
|
+
logger$c.error('failed_to_auto_create_authorizer', {
|
|
38233
37740
|
error: error instanceof Error ? error.message : String(error),
|
|
38234
37741
|
exc_info: true,
|
|
38235
37742
|
});
|
|
@@ -38258,7 +37765,7 @@ class DefaultSecurityManagerFactory extends SecurityManagerFactory {
|
|
|
38258
37765
|
});
|
|
38259
37766
|
}
|
|
38260
37767
|
catch (error) {
|
|
38261
|
-
logger$
|
|
37768
|
+
logger$c.error('failed_to_auto_create_certificate_manager', {
|
|
38262
37769
|
error: error instanceof Error ? error.message : String(error),
|
|
38263
37770
|
exc_info: true,
|
|
38264
37771
|
});
|
|
@@ -38329,11 +37836,11 @@ class DefaultSecurityManagerFactory extends SecurityManagerFactory {
|
|
|
38329
37836
|
var defaultSecurityManagerFactory = /*#__PURE__*/Object.freeze({
|
|
38330
37837
|
__proto__: null,
|
|
38331
37838
|
DefaultSecurityManagerFactory: DefaultSecurityManagerFactory,
|
|
38332
|
-
FACTORY_META: FACTORY_META$
|
|
37839
|
+
FACTORY_META: FACTORY_META$n,
|
|
38333
37840
|
default: DefaultSecurityManagerFactory
|
|
38334
37841
|
});
|
|
38335
37842
|
|
|
38336
|
-
const FACTORY_META$
|
|
37843
|
+
const FACTORY_META$m = {
|
|
38337
37844
|
base: ENCRYPTION_MANAGER_FACTORY_BASE_TYPE,
|
|
38338
37845
|
key: 'NoopEncryptionManager',
|
|
38339
37846
|
};
|
|
@@ -38390,7 +37897,7 @@ class NoopEncryptionManagerFactory extends EncryptionManagerFactory {
|
|
|
38390
37897
|
|
|
38391
37898
|
var noopEncryptionManagerFactory = /*#__PURE__*/Object.freeze({
|
|
38392
37899
|
__proto__: null,
|
|
38393
|
-
FACTORY_META: FACTORY_META$
|
|
37900
|
+
FACTORY_META: FACTORY_META$m,
|
|
38394
37901
|
NoopEncryptionManagerFactory: NoopEncryptionManagerFactory,
|
|
38395
37902
|
default: NoopEncryptionManagerFactory
|
|
38396
37903
|
});
|
|
@@ -38462,7 +37969,7 @@ class NoopSecureChannelManager {
|
|
|
38462
37969
|
}
|
|
38463
37970
|
}
|
|
38464
37971
|
|
|
38465
|
-
const FACTORY_META$
|
|
37972
|
+
const FACTORY_META$l = {
|
|
38466
37973
|
base: SECURE_CHANNEL_MANAGER_FACTORY_BASE_TYPE,
|
|
38467
37974
|
key: 'NoopSecureChannelManager',
|
|
38468
37975
|
};
|
|
@@ -38479,12 +37986,12 @@ class NoopSecureChannelManagerFactory extends SecureChannelManagerFactory {
|
|
|
38479
37986
|
|
|
38480
37987
|
var noopSecureChannelManagerFactory = /*#__PURE__*/Object.freeze({
|
|
38481
37988
|
__proto__: null,
|
|
38482
|
-
FACTORY_META: FACTORY_META$
|
|
37989
|
+
FACTORY_META: FACTORY_META$l,
|
|
38483
37990
|
NoopSecureChannelManagerFactory: NoopSecureChannelManagerFactory,
|
|
38484
37991
|
default: NoopSecureChannelManagerFactory
|
|
38485
37992
|
});
|
|
38486
37993
|
|
|
38487
|
-
const FACTORY_META$
|
|
37994
|
+
const FACTORY_META$k = {
|
|
38488
37995
|
base: KEY_MANAGER_FACTORY_BASE_TYPE,
|
|
38489
37996
|
key: 'DefaultKeyManager',
|
|
38490
37997
|
};
|
|
@@ -38513,11 +38020,11 @@ class DefaultKeyManagerFactory extends KeyManagerFactory {
|
|
|
38513
38020
|
var defaultKeyManagerFactory = /*#__PURE__*/Object.freeze({
|
|
38514
38021
|
__proto__: null,
|
|
38515
38022
|
DefaultKeyManagerFactory: DefaultKeyManagerFactory,
|
|
38516
|
-
FACTORY_META: FACTORY_META$
|
|
38023
|
+
FACTORY_META: FACTORY_META$k,
|
|
38517
38024
|
default: DefaultKeyManagerFactory
|
|
38518
38025
|
});
|
|
38519
38026
|
|
|
38520
|
-
const logger$
|
|
38027
|
+
const logger$b = getLogger('naylence.fame.security.keys.in_memory_key_store');
|
|
38521
38028
|
class InMemoryKeyStore extends KeyStore {
|
|
38522
38029
|
constructor(initialKeys = null) {
|
|
38523
38030
|
super();
|
|
@@ -38539,7 +38046,7 @@ class InMemoryKeyStore extends KeyStore {
|
|
|
38539
38046
|
}
|
|
38540
38047
|
catch (error) {
|
|
38541
38048
|
if (error instanceof JWKValidationError) {
|
|
38542
|
-
logger$
|
|
38049
|
+
logger$b.warning('rejected_invalid_jwk_individual', {
|
|
38543
38050
|
kid,
|
|
38544
38051
|
error: error.message,
|
|
38545
38052
|
});
|
|
@@ -38583,7 +38090,7 @@ class InMemoryKeyStore extends KeyStore {
|
|
|
38583
38090
|
}
|
|
38584
38091
|
}
|
|
38585
38092
|
if (staleKeys.length > 0) {
|
|
38586
|
-
logger$
|
|
38093
|
+
logger$b.debug('removing_stale_keys_before_adding_new_key', {
|
|
38587
38094
|
new_kid: kid,
|
|
38588
38095
|
physical_path: physicalPath,
|
|
38589
38096
|
base_path: basePath,
|
|
@@ -38611,7 +38118,7 @@ class InMemoryKeyStore extends KeyStore {
|
|
|
38611
38118
|
}
|
|
38612
38119
|
keysByPath[path].push(existingKid);
|
|
38613
38120
|
}
|
|
38614
|
-
logger$
|
|
38121
|
+
logger$b.debug('key_lookup_failed', {
|
|
38615
38122
|
missing_kid: kid,
|
|
38616
38123
|
available_kids: Array.from(this.keys.keys()),
|
|
38617
38124
|
keys_by_path: keysByPath,
|
|
@@ -38660,7 +38167,7 @@ class InMemoryKeyStore extends KeyStore {
|
|
|
38660
38167
|
this.keys.delete(kid);
|
|
38661
38168
|
}
|
|
38662
38169
|
if (keysToRemove.length > 0) {
|
|
38663
|
-
logger$
|
|
38170
|
+
logger$b.debug('removed_keys_for_path', {
|
|
38664
38171
|
physical_path: physicalPath,
|
|
38665
38172
|
removed_key_ids: keysToRemove,
|
|
38666
38173
|
count: keysToRemove.length,
|
|
@@ -38671,7 +38178,7 @@ class InMemoryKeyStore extends KeyStore {
|
|
|
38671
38178
|
async removeKey(kid) {
|
|
38672
38179
|
const removed = this.keys.delete(kid);
|
|
38673
38180
|
if (removed) {
|
|
38674
|
-
logger$
|
|
38181
|
+
logger$b.debug('removed_individual_key', { kid });
|
|
38675
38182
|
}
|
|
38676
38183
|
return removed;
|
|
38677
38184
|
}
|
|
@@ -38698,7 +38205,7 @@ class InMemoryKeyStore extends KeyStore {
|
|
|
38698
38205
|
}
|
|
38699
38206
|
registerDefaultKeyStoreFactory(() => new InMemoryKeyStore());
|
|
38700
38207
|
|
|
38701
|
-
const FACTORY_META$
|
|
38208
|
+
const FACTORY_META$j = {
|
|
38702
38209
|
base: KEY_STORE_FACTORY_BASE_TYPE,
|
|
38703
38210
|
key: 'InMemoryKeyStore',
|
|
38704
38211
|
};
|
|
@@ -38733,12 +38240,12 @@ class InMemoryKeyStoreFactory extends KeyStoreFactory {
|
|
|
38733
38240
|
|
|
38734
38241
|
var inMemoryKeyStoreFactory = /*#__PURE__*/Object.freeze({
|
|
38735
38242
|
__proto__: null,
|
|
38736
|
-
FACTORY_META: FACTORY_META$
|
|
38243
|
+
FACTORY_META: FACTORY_META$j,
|
|
38737
38244
|
InMemoryKeyStoreFactory: InMemoryKeyStoreFactory,
|
|
38738
38245
|
default: InMemoryKeyStoreFactory
|
|
38739
38246
|
});
|
|
38740
38247
|
|
|
38741
|
-
const FACTORY_META$
|
|
38248
|
+
const FACTORY_META$i = {
|
|
38742
38249
|
base: ATTACHMENT_KEY_VALIDATOR_FACTORY_BASE_TYPE,
|
|
38743
38250
|
key: 'NoopKeyValidator',
|
|
38744
38251
|
};
|
|
@@ -38756,12 +38263,12 @@ class NoopKeyValidatorFactory extends AttachmentKeyValidatorFactory {
|
|
|
38756
38263
|
|
|
38757
38264
|
var noopKeyValidatorFactory = /*#__PURE__*/Object.freeze({
|
|
38758
38265
|
__proto__: null,
|
|
38759
|
-
FACTORY_META: FACTORY_META$
|
|
38266
|
+
FACTORY_META: FACTORY_META$i,
|
|
38760
38267
|
NoopKeyValidatorFactory: NoopKeyValidatorFactory,
|
|
38761
38268
|
default: NoopKeyValidatorFactory
|
|
38762
38269
|
});
|
|
38763
38270
|
|
|
38764
|
-
const FACTORY_META$
|
|
38271
|
+
const FACTORY_META$h = {
|
|
38765
38272
|
base: SECURITY_POLICY_FACTORY_BASE_TYPE,
|
|
38766
38273
|
key: 'DefaultSecurityPolicy',
|
|
38767
38274
|
};
|
|
@@ -38779,7 +38286,7 @@ class DefaultSecurityPolicyFactory extends SecurityPolicyFactory {
|
|
|
38779
38286
|
* - factoryArgs[0]: KeyProvider | null (optional) - Key provider for key lookups
|
|
38780
38287
|
*/
|
|
38781
38288
|
async create(config, ...factoryArgs) {
|
|
38782
|
-
const prepared = normalizeConfig$
|
|
38289
|
+
const prepared = normalizeConfig$3(config);
|
|
38783
38290
|
const options = {};
|
|
38784
38291
|
// Extract keyProvider from factoryArgs[0] (matches Python's key_provider kwarg)
|
|
38785
38292
|
const keyProvider = factoryArgs[0];
|
|
@@ -38796,7 +38303,7 @@ class DefaultSecurityPolicyFactory extends SecurityPolicyFactory {
|
|
|
38796
38303
|
return new DefaultSecurityPolicy(options);
|
|
38797
38304
|
}
|
|
38798
38305
|
}
|
|
38799
|
-
function normalizeConfig$
|
|
38306
|
+
function normalizeConfig$3(config) {
|
|
38800
38307
|
if (!config) {
|
|
38801
38308
|
return { type: 'DefaultSecurityPolicy' };
|
|
38802
38309
|
}
|
|
@@ -38822,11 +38329,11 @@ function normalizeConfig$2(config) {
|
|
|
38822
38329
|
var defaultSecurityPolicyFactory = /*#__PURE__*/Object.freeze({
|
|
38823
38330
|
__proto__: null,
|
|
38824
38331
|
DefaultSecurityPolicyFactory: DefaultSecurityPolicyFactory,
|
|
38825
|
-
FACTORY_META: FACTORY_META$
|
|
38332
|
+
FACTORY_META: FACTORY_META$h,
|
|
38826
38333
|
default: DefaultSecurityPolicyFactory
|
|
38827
38334
|
});
|
|
38828
38335
|
|
|
38829
|
-
const FACTORY_META$
|
|
38336
|
+
const FACTORY_META$g = {
|
|
38830
38337
|
base: SECURITY_POLICY_FACTORY_BASE_TYPE,
|
|
38831
38338
|
key: 'NoSecurityPolicy',
|
|
38832
38339
|
};
|
|
@@ -38836,11 +38343,11 @@ class NoSecurityPolicyFactory extends SecurityPolicyFactory {
|
|
|
38836
38343
|
this.type = 'NoSecurityPolicy';
|
|
38837
38344
|
}
|
|
38838
38345
|
async create(config) {
|
|
38839
|
-
void normalizeConfig$
|
|
38346
|
+
void normalizeConfig$2(config);
|
|
38840
38347
|
return new NoSecurityPolicy();
|
|
38841
38348
|
}
|
|
38842
38349
|
}
|
|
38843
|
-
function normalizeConfig$
|
|
38350
|
+
function normalizeConfig$2(config) {
|
|
38844
38351
|
if (!config) {
|
|
38845
38352
|
return { type: 'NoSecurityPolicy' };
|
|
38846
38353
|
}
|
|
@@ -38854,7 +38361,7 @@ function normalizeConfig$1(config) {
|
|
|
38854
38361
|
|
|
38855
38362
|
var noSecurityPolicyFactory = /*#__PURE__*/Object.freeze({
|
|
38856
38363
|
__proto__: null,
|
|
38857
|
-
FACTORY_META: FACTORY_META$
|
|
38364
|
+
FACTORY_META: FACTORY_META$g,
|
|
38858
38365
|
NoSecurityPolicyFactory: NoSecurityPolicyFactory,
|
|
38859
38366
|
default: NoSecurityPolicyFactory
|
|
38860
38367
|
});
|
|
@@ -38869,7 +38376,7 @@ async function getEdDSAEnvelopeSignerModule() {
|
|
|
38869
38376
|
}
|
|
38870
38377
|
return eddsaEnvelopeSignerModulePromise;
|
|
38871
38378
|
}
|
|
38872
|
-
const FACTORY_META$
|
|
38379
|
+
const FACTORY_META$f = {
|
|
38873
38380
|
base: ENVELOPE_SIGNER_FACTORY_BASE_TYPE,
|
|
38874
38381
|
key: 'EdDSAEnvelopeSigner',
|
|
38875
38382
|
};
|
|
@@ -38898,7 +38405,7 @@ class EdDSAEnvelopeSignerFactory extends EnvelopeSignerFactory {
|
|
|
38898
38405
|
var eddsaEnvelopeSignerFactory = /*#__PURE__*/Object.freeze({
|
|
38899
38406
|
__proto__: null,
|
|
38900
38407
|
EdDSAEnvelopeSignerFactory: EdDSAEnvelopeSignerFactory,
|
|
38901
|
-
FACTORY_META: FACTORY_META$
|
|
38408
|
+
FACTORY_META: FACTORY_META$f,
|
|
38902
38409
|
default: EdDSAEnvelopeSignerFactory
|
|
38903
38410
|
});
|
|
38904
38411
|
|
|
@@ -38912,7 +38419,7 @@ async function getEdDSAEnvelopeVerifierModule() {
|
|
|
38912
38419
|
}
|
|
38913
38420
|
return eddsaEnvelopeVerifierModulePromise;
|
|
38914
38421
|
}
|
|
38915
|
-
const FACTORY_META$
|
|
38422
|
+
const FACTORY_META$e = {
|
|
38916
38423
|
base: ENVELOPE_VERIFIER_FACTORY_BASE_TYPE,
|
|
38917
38424
|
key: 'EdDSAEnvelopeVerifier',
|
|
38918
38425
|
};
|
|
@@ -38938,11 +38445,11 @@ class EdDSAEnvelopeVerifierFactory extends EnvelopeVerifierFactory {
|
|
|
38938
38445
|
var eddsaEnvelopeVerifierFactory = /*#__PURE__*/Object.freeze({
|
|
38939
38446
|
__proto__: null,
|
|
38940
38447
|
EdDSAEnvelopeVerifierFactory: EdDSAEnvelopeVerifierFactory,
|
|
38941
|
-
FACTORY_META: FACTORY_META$
|
|
38448
|
+
FACTORY_META: FACTORY_META$e,
|
|
38942
38449
|
default: EdDSAEnvelopeVerifierFactory
|
|
38943
38450
|
});
|
|
38944
38451
|
|
|
38945
|
-
const FACTORY_META$
|
|
38452
|
+
const FACTORY_META$d = {
|
|
38946
38453
|
base: TRUST_STORE_PROVIDER_FACTORY_BASE_TYPE,
|
|
38947
38454
|
key: "NoopTrustStoreProvider",
|
|
38948
38455
|
isDefault: true,
|
|
@@ -38962,12 +38469,12 @@ class NoopTrustStoreProviderFactory extends TrustStoreProviderFactory {
|
|
|
38962
38469
|
|
|
38963
38470
|
var noopTrustStoreProviderFactory = /*#__PURE__*/Object.freeze({
|
|
38964
38471
|
__proto__: null,
|
|
38965
|
-
FACTORY_META: FACTORY_META$
|
|
38472
|
+
FACTORY_META: FACTORY_META$d,
|
|
38966
38473
|
NoopTrustStoreProviderFactory: NoopTrustStoreProviderFactory,
|
|
38967
38474
|
default: NoopTrustStoreProviderFactory
|
|
38968
38475
|
});
|
|
38969
38476
|
|
|
38970
|
-
const FACTORY_META$
|
|
38477
|
+
const FACTORY_META$c = {
|
|
38971
38478
|
base: ROUTING_POLICY_FACTORY_BASE,
|
|
38972
38479
|
key: 'CapabilityAwareRoutingPolicy',
|
|
38973
38480
|
};
|
|
@@ -39033,12 +38540,12 @@ class CapabilityAwareRoutingPolicyFactory extends RoutingPolicyFactory {
|
|
|
39033
38540
|
var capabilityAwareRoutingPolicyFactory = /*#__PURE__*/Object.freeze({
|
|
39034
38541
|
__proto__: null,
|
|
39035
38542
|
CapabilityAwareRoutingPolicyFactory: CapabilityAwareRoutingPolicyFactory,
|
|
39036
|
-
FACTORY_META: FACTORY_META$
|
|
38543
|
+
FACTORY_META: FACTORY_META$c,
|
|
39037
38544
|
default: CapabilityAwareRoutingPolicyFactory
|
|
39038
38545
|
});
|
|
39039
38546
|
|
|
39040
|
-
const logger$
|
|
39041
|
-
const FACTORY_META$
|
|
38547
|
+
const logger$a = getLogger('naylence.fame.sentinel.composite_routing_policy_factory');
|
|
38548
|
+
const FACTORY_META$b = {
|
|
39042
38549
|
base: ROUTING_POLICY_FACTORY_BASE,
|
|
39043
38550
|
key: 'CompositeRoutingPolicy',
|
|
39044
38551
|
};
|
|
@@ -39063,13 +38570,13 @@ class CompositeRoutingPolicyFactory extends RoutingPolicyFactory {
|
|
|
39063
38570
|
policies.push(policy);
|
|
39064
38571
|
}
|
|
39065
38572
|
else {
|
|
39066
|
-
logger$
|
|
38573
|
+
logger$a.warning('composite_policy_null_child', {
|
|
39067
38574
|
config: policyConfig,
|
|
39068
38575
|
});
|
|
39069
38576
|
}
|
|
39070
38577
|
}
|
|
39071
38578
|
catch (error) {
|
|
39072
|
-
logger$
|
|
38579
|
+
logger$a.warning('composite_policy_child_error', {
|
|
39073
38580
|
error: error instanceof Error ? error.message : String(error),
|
|
39074
38581
|
config: policyConfig,
|
|
39075
38582
|
});
|
|
@@ -39162,11 +38669,11 @@ function getFirstDefined(record, keys) {
|
|
|
39162
38669
|
var compositeRoutingPolicyFactory = /*#__PURE__*/Object.freeze({
|
|
39163
38670
|
__proto__: null,
|
|
39164
38671
|
CompositeRoutingPolicyFactory: CompositeRoutingPolicyFactory,
|
|
39165
|
-
FACTORY_META: FACTORY_META$
|
|
38672
|
+
FACTORY_META: FACTORY_META$b,
|
|
39166
38673
|
default: CompositeRoutingPolicyFactory
|
|
39167
38674
|
});
|
|
39168
38675
|
|
|
39169
|
-
const FACTORY_META$
|
|
38676
|
+
const FACTORY_META$a = {
|
|
39170
38677
|
base: ROUTING_POLICY_FACTORY_BASE,
|
|
39171
38678
|
key: 'HybridPathRoutingPolicy',
|
|
39172
38679
|
};
|
|
@@ -39228,12 +38735,12 @@ class HybridPathRoutingPolicyFactory extends RoutingPolicyFactory {
|
|
|
39228
38735
|
|
|
39229
38736
|
var hybridPathRoutingPolicyFactory = /*#__PURE__*/Object.freeze({
|
|
39230
38737
|
__proto__: null,
|
|
39231
|
-
FACTORY_META: FACTORY_META$
|
|
38738
|
+
FACTORY_META: FACTORY_META$a,
|
|
39232
38739
|
HybridPathRoutingPolicyFactory: HybridPathRoutingPolicyFactory,
|
|
39233
38740
|
default: HybridPathRoutingPolicyFactory
|
|
39234
38741
|
});
|
|
39235
38742
|
|
|
39236
|
-
const FACTORY_META$
|
|
38743
|
+
const FACTORY_META$9 = {
|
|
39237
38744
|
base: LOAD_BALANCING_STRATEGY_FACTORY_BASE,
|
|
39238
38745
|
key: 'CompositeLoadBalancingStrategy',
|
|
39239
38746
|
};
|
|
@@ -39292,11 +38799,11 @@ class CompositeLoadBalancingStrategyFactory extends LoadBalancingStrategyFactory
|
|
|
39292
38799
|
var compositeLoadBalancingStrategyFactory = /*#__PURE__*/Object.freeze({
|
|
39293
38800
|
__proto__: null,
|
|
39294
38801
|
CompositeLoadBalancingStrategyFactory: CompositeLoadBalancingStrategyFactory,
|
|
39295
|
-
FACTORY_META: FACTORY_META$
|
|
38802
|
+
FACTORY_META: FACTORY_META$9,
|
|
39296
38803
|
default: CompositeLoadBalancingStrategyFactory
|
|
39297
38804
|
});
|
|
39298
38805
|
|
|
39299
|
-
const FACTORY_META$
|
|
38806
|
+
const FACTORY_META$8 = {
|
|
39300
38807
|
base: LOAD_BALANCING_STRATEGY_FACTORY_BASE,
|
|
39301
38808
|
key: 'HRWLoadBalancingStrategy',
|
|
39302
38809
|
};
|
|
@@ -39359,13 +38866,13 @@ async function createDefaultHRWStrategy(config) {
|
|
|
39359
38866
|
|
|
39360
38867
|
var hrwLoadBalancingStrategyFactory = /*#__PURE__*/Object.freeze({
|
|
39361
38868
|
__proto__: null,
|
|
39362
|
-
FACTORY_META: FACTORY_META$
|
|
38869
|
+
FACTORY_META: FACTORY_META$8,
|
|
39363
38870
|
HRWLoadBalancingStrategyFactory: HRWLoadBalancingStrategyFactory,
|
|
39364
38871
|
createDefaultHRWStrategy: createDefaultHRWStrategy,
|
|
39365
38872
|
default: HRWLoadBalancingStrategyFactory
|
|
39366
38873
|
});
|
|
39367
38874
|
|
|
39368
|
-
const logger$
|
|
38875
|
+
const logger$9 = getLogger('naylence.fame.sentinel.load_balancing.load_balancing_profile_factory');
|
|
39369
38876
|
const PROFILE_NAME_RANDOM = 'random';
|
|
39370
38877
|
const PROFILE_NAME_ROUND_ROBIN = 'round_robin';
|
|
39371
38878
|
const PROFILE_NAME_HRW = 'hrw';
|
|
@@ -39387,7 +38894,7 @@ const STICKY_HRW_PROFILE = {
|
|
|
39387
38894
|
const DEVELOPMENT_PROFILE$1 = {
|
|
39388
38895
|
type: 'RoundRobinLoadBalancingStrategy',
|
|
39389
38896
|
};
|
|
39390
|
-
const FACTORY_META$
|
|
38897
|
+
const FACTORY_META$7 = {
|
|
39391
38898
|
base: LOAD_BALANCING_STRATEGY_FACTORY_BASE,
|
|
39392
38899
|
key: 'LoadBalancingProfile',
|
|
39393
38900
|
};
|
|
@@ -39399,7 +38906,7 @@ class LoadBalancingProfileFactory extends LoadBalancingStrategyFactory {
|
|
|
39399
38906
|
async create(config, ...factoryArgs) {
|
|
39400
38907
|
const finalConfig = this.normalizeConfig(config);
|
|
39401
38908
|
const profileName = finalConfig.profile ?? PROFILE_NAME_DEVELOPMENT$1;
|
|
39402
|
-
logger$
|
|
38909
|
+
logger$9.debug('enabling_load_balancing_profile', { profile: profileName });
|
|
39403
38910
|
const strategyConfig = this.resolveProfile(profileName);
|
|
39404
38911
|
const strategy = await factory.createResource(LOAD_BALANCING_STRATEGY_FACTORY_BASE, strategyConfig, { factoryArgs });
|
|
39405
38912
|
if (!strategy) {
|
|
@@ -39460,7 +38967,7 @@ class LoadBalancingProfileFactory extends LoadBalancingStrategyFactory {
|
|
|
39460
38967
|
|
|
39461
38968
|
var loadBalancingProfileFactory = /*#__PURE__*/Object.freeze({
|
|
39462
38969
|
__proto__: null,
|
|
39463
|
-
FACTORY_META: FACTORY_META$
|
|
38970
|
+
FACTORY_META: FACTORY_META$7,
|
|
39464
38971
|
LoadBalancingProfileFactory: LoadBalancingProfileFactory,
|
|
39465
38972
|
PROFILE_NAME_DEVELOPMENT: PROFILE_NAME_DEVELOPMENT$1,
|
|
39466
38973
|
PROFILE_NAME_HRW: PROFILE_NAME_HRW,
|
|
@@ -39487,7 +38994,7 @@ class RandomLoadBalancingStrategy {
|
|
|
39487
38994
|
}
|
|
39488
38995
|
}
|
|
39489
38996
|
|
|
39490
|
-
const FACTORY_META$
|
|
38997
|
+
const FACTORY_META$6 = {
|
|
39491
38998
|
base: LOAD_BALANCING_STRATEGY_FACTORY_BASE,
|
|
39492
38999
|
key: 'RandomLoadBalancingStrategy',
|
|
39493
39000
|
};
|
|
@@ -39503,7 +39010,7 @@ class RandomLoadBalancingStrategyFactory extends LoadBalancingStrategyFactory {
|
|
|
39503
39010
|
|
|
39504
39011
|
var randomLoadBalancingStrategyFactory = /*#__PURE__*/Object.freeze({
|
|
39505
39012
|
__proto__: null,
|
|
39506
|
-
FACTORY_META: FACTORY_META$
|
|
39013
|
+
FACTORY_META: FACTORY_META$6,
|
|
39507
39014
|
RandomLoadBalancingStrategyFactory: RandomLoadBalancingStrategyFactory,
|
|
39508
39015
|
default: RandomLoadBalancingStrategyFactory
|
|
39509
39016
|
});
|
|
@@ -39523,7 +39030,7 @@ class RoundRobinLoadBalancingStrategy {
|
|
|
39523
39030
|
}
|
|
39524
39031
|
}
|
|
39525
39032
|
|
|
39526
|
-
const FACTORY_META$
|
|
39033
|
+
const FACTORY_META$5 = {
|
|
39527
39034
|
base: LOAD_BALANCING_STRATEGY_FACTORY_BASE,
|
|
39528
39035
|
key: 'RoundRobinLoadBalancingStrategy',
|
|
39529
39036
|
};
|
|
@@ -39539,12 +39046,12 @@ class RoundRobinLoadBalancingStrategyFactory extends LoadBalancingStrategyFactor
|
|
|
39539
39046
|
|
|
39540
39047
|
var roundRobinLoadBalancingStrategyFactory = /*#__PURE__*/Object.freeze({
|
|
39541
39048
|
__proto__: null,
|
|
39542
|
-
FACTORY_META: FACTORY_META$
|
|
39049
|
+
FACTORY_META: FACTORY_META$5,
|
|
39543
39050
|
RoundRobinLoadBalancingStrategyFactory: RoundRobinLoadBalancingStrategyFactory,
|
|
39544
39051
|
default: RoundRobinLoadBalancingStrategyFactory
|
|
39545
39052
|
});
|
|
39546
39053
|
|
|
39547
|
-
const FACTORY_META$
|
|
39054
|
+
const FACTORY_META$4 = {
|
|
39548
39055
|
base: LOAD_BALANCING_STRATEGY_FACTORY_BASE,
|
|
39549
39056
|
key: 'StickyLoadBalancingStrategy',
|
|
39550
39057
|
};
|
|
@@ -39585,12 +39092,12 @@ class StickyLoadBalancingStrategyFactory extends LoadBalancingStrategyFactory {
|
|
|
39585
39092
|
|
|
39586
39093
|
var stickyLoadBalancingStrategyFactory = /*#__PURE__*/Object.freeze({
|
|
39587
39094
|
__proto__: null,
|
|
39588
|
-
FACTORY_META: FACTORY_META$
|
|
39095
|
+
FACTORY_META: FACTORY_META$4,
|
|
39589
39096
|
StickyLoadBalancingStrategyFactory: StickyLoadBalancingStrategyFactory,
|
|
39590
39097
|
default: StickyLoadBalancingStrategyFactory
|
|
39591
39098
|
});
|
|
39592
39099
|
|
|
39593
|
-
const logger$
|
|
39100
|
+
const logger$8 = getLogger('naylence.fame.sentinel.routing_profile_factory');
|
|
39594
39101
|
const PROFILE_NAME_DEVELOPMENT = 'development';
|
|
39595
39102
|
const PROFILE_NAME_PRODUCTION = 'production';
|
|
39596
39103
|
const PROFILE_NAME_BASIC = 'basic';
|
|
@@ -39623,14 +39130,14 @@ const HYBRID_ONLY_PROFILE = {
|
|
|
39623
39130
|
type: 'HybridPathRoutingPolicy',
|
|
39624
39131
|
loadBalancingStrategy: { type: 'HRWLoadBalancingStrategy' },
|
|
39625
39132
|
};
|
|
39626
|
-
const PROFILE_MAP = {
|
|
39133
|
+
const PROFILE_MAP$1 = {
|
|
39627
39134
|
[PROFILE_NAME_DEVELOPMENT]: DEVELOPMENT_PROFILE,
|
|
39628
39135
|
[PROFILE_NAME_PRODUCTION]: PRODUCTION_PROFILE,
|
|
39629
39136
|
[PROFILE_NAME_BASIC]: BASIC_PROFILE,
|
|
39630
39137
|
[PROFILE_NAME_CAPABILITY_AWARE]: CAPABILITY_AWARE_PROFILE,
|
|
39631
39138
|
[PROFILE_NAME_HYBRID_ONLY]: HYBRID_ONLY_PROFILE,
|
|
39632
39139
|
};
|
|
39633
|
-
const FACTORY_META = {
|
|
39140
|
+
const FACTORY_META$3 = {
|
|
39634
39141
|
base: ROUTING_POLICY_FACTORY_BASE,
|
|
39635
39142
|
key: 'RoutingProfile',
|
|
39636
39143
|
};
|
|
@@ -39641,7 +39148,7 @@ class RoutingProfileFactory extends RoutingPolicyFactory {
|
|
|
39641
39148
|
}
|
|
39642
39149
|
async create(config, ...kwargs) {
|
|
39643
39150
|
const normalized = this.normalizeConfig(config);
|
|
39644
|
-
logger$
|
|
39151
|
+
logger$8.debug('enabling_routing_profile', { profile: normalized.profile });
|
|
39645
39152
|
const routingConfig = this.getProfileConfig(normalized.profile);
|
|
39646
39153
|
const policy = await factory.createResource(ROUTING_POLICY_FACTORY_BASE, routingConfig, {
|
|
39647
39154
|
factoryArgs: kwargs,
|
|
@@ -39684,7 +39191,7 @@ class RoutingProfileFactory extends RoutingPolicyFactory {
|
|
|
39684
39191
|
return undefined;
|
|
39685
39192
|
}
|
|
39686
39193
|
getProfileConfig(profile) {
|
|
39687
|
-
const routingConfig = PROFILE_MAP[profile];
|
|
39194
|
+
const routingConfig = PROFILE_MAP$1[profile];
|
|
39688
39195
|
if (!routingConfig) {
|
|
39689
39196
|
throw new Error('Unknown routing profile');
|
|
39690
39197
|
}
|
|
@@ -39694,7 +39201,7 @@ class RoutingProfileFactory extends RoutingPolicyFactory {
|
|
|
39694
39201
|
|
|
39695
39202
|
var routingProfileFactory = /*#__PURE__*/Object.freeze({
|
|
39696
39203
|
__proto__: null,
|
|
39697
|
-
FACTORY_META: FACTORY_META,
|
|
39204
|
+
FACTORY_META: FACTORY_META$3,
|
|
39698
39205
|
PROFILE_NAME_BASIC: PROFILE_NAME_BASIC,
|
|
39699
39206
|
PROFILE_NAME_CAPABILITY_AWARE: PROFILE_NAME_CAPABILITY_AWARE,
|
|
39700
39207
|
PROFILE_NAME_DEVELOPMENT: PROFILE_NAME_DEVELOPMENT,
|
|
@@ -39704,470 +39211,495 @@ var routingProfileFactory = /*#__PURE__*/Object.freeze({
|
|
|
39704
39211
|
default: RoutingProfileFactory
|
|
39705
39212
|
});
|
|
39706
39213
|
|
|
39707
|
-
|
|
39708
|
-
|
|
39709
|
-
|
|
39710
|
-
|
|
39711
|
-
|
|
39712
|
-
|
|
39713
|
-
|
|
39714
|
-
// console.log('[naylence:runtime] already initialized, skipping');
|
|
39715
|
-
return;
|
|
39716
|
-
}
|
|
39717
|
-
initialized = true;
|
|
39718
|
-
// console.log('[naylence:runtime] registering runtime factories...');
|
|
39719
|
-
// Register factories from manifest
|
|
39720
|
-
await registerRuntimeFactories();
|
|
39721
|
-
// Import modules with side-effect registrations (not in manifest)
|
|
39722
|
-
await Promise.resolve().then(function () { return websocketTransportProvisioner; });
|
|
39723
|
-
// console.log('[naylence:runtime] runtime factories registered');
|
|
39724
|
-
},
|
|
39725
|
-
};
|
|
39726
|
-
const RUNTIME_PLUGIN_SPECIFIER = runtimePlugin.name;
|
|
39727
|
-
|
|
39728
|
-
var plugin = /*#__PURE__*/Object.freeze({
|
|
39729
|
-
__proto__: null,
|
|
39730
|
-
RUNTIME_PLUGIN_SPECIFIER: RUNTIME_PLUGIN_SPECIFIER,
|
|
39731
|
-
default: runtimePlugin
|
|
39732
|
-
});
|
|
39733
|
-
|
|
39734
|
-
let currentTraceId = null;
|
|
39735
|
-
let currentSpanId = null;
|
|
39736
|
-
function getOtelTraceId() {
|
|
39737
|
-
return currentTraceId;
|
|
39738
|
-
}
|
|
39739
|
-
function getOtelSpanId() {
|
|
39740
|
-
return currentSpanId;
|
|
39741
|
-
}
|
|
39742
|
-
function setOtelTraceId(traceId) {
|
|
39743
|
-
const previous = currentTraceId;
|
|
39744
|
-
currentTraceId = traceId;
|
|
39745
|
-
return previous;
|
|
39746
|
-
}
|
|
39747
|
-
function setOtelSpanId(spanId) {
|
|
39748
|
-
const previous = currentSpanId;
|
|
39749
|
-
currentSpanId = spanId;
|
|
39750
|
-
return previous;
|
|
39751
|
-
}
|
|
39752
|
-
function resetOtelTraceId(previous) {
|
|
39753
|
-
currentTraceId = previous;
|
|
39214
|
+
const telemetryLogger = getLogger('naylence.fame.telemetry.base_trace_emitter');
|
|
39215
|
+
function logTelemetryFailure(event, error, context = {}) {
|
|
39216
|
+
telemetryLogger.warning(event, {
|
|
39217
|
+
...context,
|
|
39218
|
+
error: error instanceof Error ? error.message : String(error),
|
|
39219
|
+
stack: error instanceof Error && error.stack ? error.stack : undefined,
|
|
39220
|
+
});
|
|
39754
39221
|
}
|
|
39755
|
-
function
|
|
39756
|
-
|
|
39222
|
+
function buildEnvelopeAttributes(envelope) {
|
|
39223
|
+
return {
|
|
39224
|
+
'env.id': envelope.id,
|
|
39225
|
+
'env.trace_id': envelope.traceId,
|
|
39226
|
+
'env.corr_id': envelope.corrId,
|
|
39227
|
+
'env.flow_id': envelope.flowId,
|
|
39228
|
+
'env.seq_id': envelope.seqId,
|
|
39229
|
+
'env.to': envelope.to ?? null,
|
|
39230
|
+
'env.priority': envelope.priority ?? null,
|
|
39231
|
+
'env.sid': envelope.sid ?? null,
|
|
39232
|
+
'env.reply_to': envelope.replyTo ?? null,
|
|
39233
|
+
'env.ts': envelope.ts?.toISOString?.() ?? null,
|
|
39234
|
+
'env.frame_type': envelope.frame
|
|
39235
|
+
? (envelope.frame.type ?? null)
|
|
39236
|
+
: null,
|
|
39237
|
+
'env.is_signed': Boolean(envelope.sec?.sig),
|
|
39238
|
+
'env.sign_kid': envelope.sec?.sig?.kid ?? null,
|
|
39239
|
+
'env.is_encrypted': Boolean(envelope.sec?.enc),
|
|
39240
|
+
'env.enc_kid': envelope.sec?.enc?.kid ?? null,
|
|
39241
|
+
};
|
|
39757
39242
|
}
|
|
39758
|
-
|
|
39759
|
-
|
|
39760
|
-
|
|
39761
|
-
|
|
39762
|
-
|
|
39763
|
-
}
|
|
39764
|
-
setAttribute(key, value) {
|
|
39765
|
-
try {
|
|
39766
|
-
this.span.setAttribute(key, normalizeAttributeValue(value));
|
|
39767
|
-
}
|
|
39768
|
-
catch {
|
|
39769
|
-
// Ignore telemetry attribute errors
|
|
39243
|
+
function filterAttributes(attributes) {
|
|
39244
|
+
const filtered = {};
|
|
39245
|
+
for (const [key, value] of Object.entries(attributes)) {
|
|
39246
|
+
if (value !== undefined && value !== null) {
|
|
39247
|
+
filtered[key] = value;
|
|
39770
39248
|
}
|
|
39771
39249
|
}
|
|
39772
|
-
|
|
39773
|
-
|
|
39774
|
-
|
|
39775
|
-
|
|
39776
|
-
|
|
39777
|
-
else {
|
|
39778
|
-
this.span.recordException(new Error(String(error)));
|
|
39779
|
-
}
|
|
39780
|
-
}
|
|
39781
|
-
catch {
|
|
39782
|
-
// Ignore telemetry recording errors
|
|
39783
|
-
}
|
|
39250
|
+
return filtered;
|
|
39251
|
+
}
|
|
39252
|
+
function extractContextValue(context, keys) {
|
|
39253
|
+
if (!context) {
|
|
39254
|
+
return undefined;
|
|
39784
39255
|
}
|
|
39785
|
-
|
|
39786
|
-
|
|
39787
|
-
|
|
39788
|
-
|
|
39789
|
-
|
|
39790
|
-
|
|
39791
|
-
status.message = description;
|
|
39256
|
+
const source = context;
|
|
39257
|
+
for (const key of keys) {
|
|
39258
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
39259
|
+
const value = source[key];
|
|
39260
|
+
if (value !== undefined) {
|
|
39261
|
+
return value;
|
|
39792
39262
|
}
|
|
39793
|
-
this.span.setStatus(status);
|
|
39794
|
-
}
|
|
39795
|
-
catch {
|
|
39796
|
-
// Ignore telemetry status errors
|
|
39797
39263
|
}
|
|
39798
39264
|
}
|
|
39265
|
+
return undefined;
|
|
39799
39266
|
}
|
|
39800
|
-
class
|
|
39801
|
-
constructor(
|
|
39802
|
-
|
|
39803
|
-
this.
|
|
39804
|
-
this.
|
|
39267
|
+
class BaseTraceEmitter extends BaseNodeEventListener {
|
|
39268
|
+
constructor() {
|
|
39269
|
+
super(...arguments);
|
|
39270
|
+
this.node = null;
|
|
39271
|
+
this.inflight = new Map();
|
|
39272
|
+
this.priority = 10000;
|
|
39805
39273
|
}
|
|
39806
|
-
|
|
39807
|
-
|
|
39808
|
-
this.entered = true;
|
|
39809
|
-
const spanContext = this.span.spanContext();
|
|
39810
|
-
this.traceToken = setOtelTraceId(spanContext?.traceId ?? null);
|
|
39811
|
-
this.spanToken = setOtelSpanId(spanContext?.spanId ?? null);
|
|
39812
|
-
}
|
|
39813
|
-
return this.wrapper;
|
|
39274
|
+
getSpanKey(envelope, operationKey) {
|
|
39275
|
+
return `${envelope.id}:${operationKey}`;
|
|
39814
39276
|
}
|
|
39815
|
-
|
|
39277
|
+
startEnvelopeOperationSpan(node, operationName, envelope, operationKey, additionalAttributes = null) {
|
|
39816
39278
|
try {
|
|
39817
|
-
this.
|
|
39818
|
-
|
|
39819
|
-
|
|
39820
|
-
|
|
39821
|
-
|
|
39822
|
-
|
|
39823
|
-
|
|
39824
|
-
|
|
39825
|
-
|
|
39279
|
+
const key = this.getSpanKey(envelope, operationKey);
|
|
39280
|
+
const previous = this.inflight.get(key);
|
|
39281
|
+
if (previous) {
|
|
39282
|
+
this.inflight.delete(key);
|
|
39283
|
+
try {
|
|
39284
|
+
previous.scope.exit();
|
|
39285
|
+
}
|
|
39286
|
+
catch (cleanupError) {
|
|
39287
|
+
logTelemetryFailure('trace_span_scope_exit_failed', cleanupError, {
|
|
39288
|
+
operation: operationName,
|
|
39289
|
+
span_key: key,
|
|
39290
|
+
});
|
|
39291
|
+
}
|
|
39826
39292
|
}
|
|
39827
|
-
|
|
39828
|
-
|
|
39829
|
-
|
|
39293
|
+
const attributes = buildEnvelopeAttributes(envelope);
|
|
39294
|
+
if (additionalAttributes) {
|
|
39295
|
+
for (const [attrKey, attrValue] of Object.entries(additionalAttributes)) {
|
|
39296
|
+
attributes[attrKey] = attrValue;
|
|
39297
|
+
}
|
|
39830
39298
|
}
|
|
39299
|
+
const effectiveNode = node ?? this.node;
|
|
39300
|
+
if (effectiveNode) {
|
|
39301
|
+
attributes['node.id'] = effectiveNode.id;
|
|
39302
|
+
attributes['node.sid'] = effectiveNode.sid ?? null;
|
|
39303
|
+
}
|
|
39304
|
+
const scope = this.startSpan(operationName, {
|
|
39305
|
+
attributes: filterAttributes(attributes),
|
|
39306
|
+
});
|
|
39307
|
+
const span = scope.enter();
|
|
39308
|
+
this.inflight.set(key, { scope, span });
|
|
39831
39309
|
}
|
|
39832
|
-
|
|
39833
|
-
|
|
39834
|
-
|
|
39835
|
-
|
|
39836
|
-
|
|
39837
|
-
this.shutdownInvoked = false;
|
|
39838
|
-
const normalized = normalizeOpenTelemetryTraceEmitterOptions(options);
|
|
39839
|
-
this.otelApi = normalized.otelApi;
|
|
39840
|
-
this.tracer =
|
|
39841
|
-
normalized.tracer ?? this.otelApi.trace.getTracer(normalized.serviceName);
|
|
39842
|
-
this.lifecycle = normalized.lifecycle ?? null;
|
|
39843
|
-
this.authStrategy = normalized.authStrategy ?? null;
|
|
39844
|
-
}
|
|
39845
|
-
startSpan(name, options) {
|
|
39846
|
-
const attributes = normalizeAttributes(options?.attributes);
|
|
39847
|
-
const spanOptions = {};
|
|
39848
|
-
if (attributes) {
|
|
39849
|
-
spanOptions.attributes = attributes;
|
|
39850
|
-
}
|
|
39851
|
-
if (options?.links) {
|
|
39852
|
-
spanOptions.links = options.links;
|
|
39853
|
-
}
|
|
39854
|
-
const span = this.tracer.startSpan(name, spanOptions);
|
|
39855
|
-
const envelopeTraceId = options?.attributes?.['env.trace_id'];
|
|
39856
|
-
if (typeof envelopeTraceId === 'string') {
|
|
39857
|
-
this.applyEnvelopeTraceId(span, envelopeTraceId);
|
|
39310
|
+
catch (error) {
|
|
39311
|
+
logTelemetryFailure('trace_span_start_failed', error, {
|
|
39312
|
+
operation: operationName,
|
|
39313
|
+
envelope_id: envelope.id,
|
|
39314
|
+
});
|
|
39858
39315
|
}
|
|
39859
|
-
return
|
|
39316
|
+
return envelope;
|
|
39860
39317
|
}
|
|
39861
|
-
|
|
39862
|
-
|
|
39863
|
-
|
|
39864
|
-
|
|
39865
|
-
|
|
39318
|
+
completeEnvelopeOperationSpan(node, operationName, envelope, operationKey, _result = null, error = null, additionalAttributes = null) {
|
|
39319
|
+
try {
|
|
39320
|
+
const key = this.getSpanKey(envelope, operationKey);
|
|
39321
|
+
let active = this.inflight.get(key);
|
|
39322
|
+
if (!active) {
|
|
39323
|
+
const attributes = buildEnvelopeAttributes(envelope);
|
|
39324
|
+
if (additionalAttributes) {
|
|
39325
|
+
for (const [attrKey, attrValue] of Object.entries(additionalAttributes)) {
|
|
39326
|
+
attributes[attrKey] = attrValue;
|
|
39327
|
+
}
|
|
39328
|
+
}
|
|
39329
|
+
const effectiveNode = node ?? this.node;
|
|
39330
|
+
if (effectiveNode) {
|
|
39331
|
+
attributes['node.id'] = effectiveNode.id;
|
|
39332
|
+
attributes['node.sid'] = effectiveNode.sid ?? null;
|
|
39333
|
+
}
|
|
39334
|
+
const scope = this.startSpan(operationName, {
|
|
39335
|
+
attributes: filterAttributes(attributes),
|
|
39336
|
+
});
|
|
39337
|
+
const span = scope.enter();
|
|
39338
|
+
active = { scope, span };
|
|
39866
39339
|
}
|
|
39867
|
-
|
|
39868
|
-
|
|
39340
|
+
else {
|
|
39341
|
+
this.inflight.delete(key);
|
|
39869
39342
|
}
|
|
39870
|
-
|
|
39871
|
-
|
|
39872
|
-
|
|
39873
|
-
|
|
39874
|
-
|
|
39343
|
+
if (error !== null && error !== undefined) {
|
|
39344
|
+
try {
|
|
39345
|
+
active.span.recordException(error);
|
|
39346
|
+
}
|
|
39347
|
+
catch (recordError) {
|
|
39348
|
+
logTelemetryFailure('trace_span_record_exception_failed', recordError, {
|
|
39349
|
+
operation: operationName,
|
|
39350
|
+
envelope_id: envelope.id,
|
|
39351
|
+
});
|
|
39352
|
+
}
|
|
39353
|
+
try {
|
|
39354
|
+
const description = error instanceof Error ? error.message : String(error);
|
|
39355
|
+
active.span.setStatusError(description);
|
|
39356
|
+
}
|
|
39357
|
+
catch (statusError) {
|
|
39358
|
+
logTelemetryFailure('trace_span_set_status_failed', statusError, {
|
|
39359
|
+
operation: operationName,
|
|
39360
|
+
envelope_id: envelope.id,
|
|
39361
|
+
});
|
|
39362
|
+
}
|
|
39875
39363
|
}
|
|
39876
|
-
}
|
|
39877
|
-
catch {
|
|
39878
|
-
// Ignore flush errors
|
|
39879
|
-
}
|
|
39880
|
-
}
|
|
39881
|
-
async shutdown() {
|
|
39882
|
-
if (this.shutdownInvoked) {
|
|
39883
|
-
return;
|
|
39884
|
-
}
|
|
39885
|
-
this.shutdownInvoked = true;
|
|
39886
|
-
const cleanupTasks = [];
|
|
39887
|
-
const strategy = this.authStrategy;
|
|
39888
|
-
if (strategy) {
|
|
39889
|
-
this.authStrategy = null;
|
|
39890
|
-
cleanupTasks.push(strategy.cleanup().catch(() => {
|
|
39891
|
-
// Ignore auth cleanup failures
|
|
39892
|
-
}));
|
|
39893
|
-
}
|
|
39894
|
-
if (this.lifecycle?.shutdown) {
|
|
39895
39364
|
try {
|
|
39896
|
-
|
|
39897
|
-
this.lifecycle = null;
|
|
39898
|
-
await Promise.all(cleanupTasks);
|
|
39899
|
-
return;
|
|
39900
|
-
}
|
|
39901
|
-
catch {
|
|
39902
|
-
// fall through to global shutdown fallback
|
|
39903
|
-
this.lifecycle = null;
|
|
39365
|
+
active.scope.exit();
|
|
39904
39366
|
}
|
|
39905
|
-
|
|
39906
|
-
|
|
39907
|
-
|
|
39908
|
-
|
|
39909
|
-
|
|
39367
|
+
catch (exitError) {
|
|
39368
|
+
logTelemetryFailure('trace_span_scope_exit_failed', exitError, {
|
|
39369
|
+
operation: operationName,
|
|
39370
|
+
envelope_id: envelope.id,
|
|
39371
|
+
});
|
|
39910
39372
|
}
|
|
39911
39373
|
}
|
|
39912
|
-
catch {
|
|
39913
|
-
|
|
39914
|
-
|
|
39915
|
-
|
|
39916
|
-
|
|
39917
|
-
await Promise.all(cleanupTasks);
|
|
39918
|
-
}
|
|
39374
|
+
catch (error) {
|
|
39375
|
+
logTelemetryFailure('trace_span_complete_failed', error, {
|
|
39376
|
+
operation: operationName,
|
|
39377
|
+
envelope_id: envelope.id,
|
|
39378
|
+
});
|
|
39919
39379
|
}
|
|
39380
|
+
return envelope;
|
|
39920
39381
|
}
|
|
39921
|
-
|
|
39382
|
+
async onEnvelopeReceived(node, envelope, context) {
|
|
39922
39383
|
try {
|
|
39923
|
-
const
|
|
39924
|
-
|
|
39925
|
-
|
|
39926
|
-
|
|
39384
|
+
const attributes = buildEnvelopeAttributes(envelope);
|
|
39385
|
+
attributes['node.id'] = node.id;
|
|
39386
|
+
attributes['node.sid'] = node.sid ?? null;
|
|
39387
|
+
const fromNodeId = extractContextValue(context, [
|
|
39388
|
+
'fromSystemId',
|
|
39389
|
+
'from_system_id',
|
|
39390
|
+
'fromNodeId',
|
|
39391
|
+
'from_node_id',
|
|
39392
|
+
]);
|
|
39393
|
+
if (fromNodeId !== undefined && fromNodeId !== null) {
|
|
39394
|
+
attributes['from.node_id'] = String(fromNodeId);
|
|
39927
39395
|
}
|
|
39396
|
+
const originType = extractContextValue(context, [
|
|
39397
|
+
'originType',
|
|
39398
|
+
'origin_type',
|
|
39399
|
+
]);
|
|
39400
|
+
if (originType !== undefined && originType !== null) {
|
|
39401
|
+
attributes['from.origin_type'] = String(originType);
|
|
39402
|
+
}
|
|
39403
|
+
const scope = this.startSpan('env.received', {
|
|
39404
|
+
attributes: filterAttributes(attributes),
|
|
39405
|
+
});
|
|
39406
|
+
scope.enter();
|
|
39407
|
+
scope.exit();
|
|
39928
39408
|
}
|
|
39929
|
-
catch {
|
|
39930
|
-
|
|
39931
|
-
|
|
39932
|
-
|
|
39933
|
-
convertEnvTraceIdToOtel(envTraceId) {
|
|
39934
|
-
const normalized = envTraceId.slice(0, 16).padEnd(16, '0');
|
|
39935
|
-
let hex = '';
|
|
39936
|
-
for (let i = 0; i < 16; i += 1) {
|
|
39937
|
-
const code = normalized.charCodeAt(i);
|
|
39938
|
-
const byte = Number.isNaN(code) ? 0 : code & 0xff;
|
|
39939
|
-
hex += byte.toString(16).padStart(2, '0');
|
|
39409
|
+
catch (error) {
|
|
39410
|
+
logTelemetryFailure('trace_span_received_failed', error, {
|
|
39411
|
+
envelope_id: envelope.id,
|
|
39412
|
+
});
|
|
39940
39413
|
}
|
|
39941
|
-
return
|
|
39414
|
+
return envelope;
|
|
39942
39415
|
}
|
|
39943
|
-
|
|
39944
|
-
|
|
39945
|
-
|
|
39946
|
-
|
|
39947
|
-
const tracer = pickFirst$1(source, ['tracer']);
|
|
39948
|
-
const otelApi = pickFirst$1(source, [
|
|
39949
|
-
'otelApi',
|
|
39950
|
-
'otel_api',
|
|
39951
|
-
]);
|
|
39952
|
-
if (!otelApi) {
|
|
39953
|
-
throw new Error('OpenTelemetryTraceEmitter requires OpenTelemetry API bindings. Provide otelApi via options.');
|
|
39416
|
+
async onForwardToRoute(node, nextSegment, envelope, _context) {
|
|
39417
|
+
return this.startEnvelopeOperationSpan(node, 'env.fwd_to_route', envelope, nextSegment, {
|
|
39418
|
+
'route.segment': nextSegment,
|
|
39419
|
+
});
|
|
39954
39420
|
}
|
|
39955
|
-
|
|
39956
|
-
'
|
|
39957
|
-
|
|
39958
|
-
|
|
39959
|
-
]) ?? null;
|
|
39960
|
-
const authStrategy = pickFirst$1(source, [
|
|
39961
|
-
'authStrategy',
|
|
39962
|
-
'auth_strategy',
|
|
39963
|
-
]) ?? null;
|
|
39964
|
-
return {
|
|
39965
|
-
serviceName,
|
|
39966
|
-
tracer,
|
|
39967
|
-
otelApi,
|
|
39968
|
-
lifecycle,
|
|
39969
|
-
authStrategy,
|
|
39970
|
-
};
|
|
39971
|
-
}
|
|
39972
|
-
function pickFirst$1(source, keys) {
|
|
39973
|
-
for (const key of keys) {
|
|
39974
|
-
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
39975
|
-
const value = source[key];
|
|
39976
|
-
if (value !== undefined) {
|
|
39977
|
-
return value;
|
|
39978
|
-
}
|
|
39979
|
-
}
|
|
39421
|
+
async onForwardToRouteComplete(node, nextSegment, envelope, result, error, _context) {
|
|
39422
|
+
return this.completeEnvelopeOperationSpan(node, 'env.fwd_to_route', envelope, nextSegment, result, error, {
|
|
39423
|
+
'route.segment': nextSegment,
|
|
39424
|
+
});
|
|
39980
39425
|
}
|
|
39981
|
-
|
|
39982
|
-
|
|
39983
|
-
|
|
39984
|
-
|
|
39985
|
-
const trimmed = value.trim();
|
|
39986
|
-
if (trimmed.length > 0) {
|
|
39987
|
-
return trimmed;
|
|
39988
|
-
}
|
|
39426
|
+
async onForwardUpstream(node, envelope, _context) {
|
|
39427
|
+
return this.startEnvelopeOperationSpan(node, 'env.fwd_upstream', envelope, 'upstream', {
|
|
39428
|
+
direction: 'upstream',
|
|
39429
|
+
});
|
|
39989
39430
|
}
|
|
39990
|
-
|
|
39991
|
-
|
|
39992
|
-
|
|
39993
|
-
|
|
39994
|
-
return value.map((item) => String(normalizePrimitiveAttribute(item, true)));
|
|
39431
|
+
async onForwardUpstreamComplete(node, envelope, result, error, _context) {
|
|
39432
|
+
return this.completeEnvelopeOperationSpan(node, 'env.fwd_upstream', envelope, 'upstream', result, error, {
|
|
39433
|
+
direction: 'upstream',
|
|
39434
|
+
});
|
|
39995
39435
|
}
|
|
39996
|
-
|
|
39997
|
-
|
|
39998
|
-
|
|
39999
|
-
|
|
40000
|
-
if (typeof value === 'string' ||
|
|
40001
|
-
typeof value === 'number' ||
|
|
40002
|
-
typeof value === 'boolean') {
|
|
40003
|
-
return value;
|
|
40004
|
-
}
|
|
40005
|
-
if (value instanceof Date) {
|
|
40006
|
-
return value.toISOString();
|
|
40007
|
-
}
|
|
39436
|
+
async onForwardToPeer(node, peerSegment, envelope, _context) {
|
|
39437
|
+
return this.startEnvelopeOperationSpan(node, 'env.fwd_to_peer', envelope, peerSegment, {
|
|
39438
|
+
'peer.segment': peerSegment,
|
|
39439
|
+
});
|
|
40008
39440
|
}
|
|
40009
|
-
|
|
40010
|
-
return
|
|
39441
|
+
async onForwardToPeerComplete(node, peerSegment, envelope, result, error, _context) {
|
|
39442
|
+
return this.completeEnvelopeOperationSpan(node, 'env.fwd_to_peer', envelope, peerSegment, result, error, {
|
|
39443
|
+
'peer.segment': peerSegment,
|
|
39444
|
+
});
|
|
40011
39445
|
}
|
|
40012
|
-
|
|
40013
|
-
|
|
39446
|
+
async onDeliverLocal(node, address, envelope, _context) {
|
|
39447
|
+
const addressKey = address ? String(address) : 'unknown';
|
|
39448
|
+
return this.startEnvelopeOperationSpan(node, 'env.deliver_local', envelope, addressKey, {
|
|
39449
|
+
'delivery.address': addressKey,
|
|
39450
|
+
'delivery.type': 'local',
|
|
39451
|
+
});
|
|
40014
39452
|
}
|
|
40015
|
-
|
|
40016
|
-
|
|
39453
|
+
async onDeliverLocalComplete(node, address, envelope, _context) {
|
|
39454
|
+
const addressKey = address ? String(address) : 'unknown';
|
|
39455
|
+
return this.completeEnvelopeOperationSpan(node, 'env.deliver_local', envelope, addressKey, null, null, {
|
|
39456
|
+
'delivery.address': addressKey,
|
|
39457
|
+
'delivery.type': 'local',
|
|
39458
|
+
});
|
|
40017
39459
|
}
|
|
40018
|
-
|
|
40019
|
-
|
|
40020
|
-
function normalizeAttributes(source) {
|
|
40021
|
-
if (!source) {
|
|
40022
|
-
return undefined;
|
|
39460
|
+
async onNodeInitialized(node) {
|
|
39461
|
+
this.node = node;
|
|
40023
39462
|
}
|
|
40024
|
-
|
|
40025
|
-
|
|
40026
|
-
|
|
39463
|
+
async onNodeStopped(_node) {
|
|
39464
|
+
try {
|
|
39465
|
+
if (typeof this.flush === 'function') {
|
|
39466
|
+
await this.flush();
|
|
39467
|
+
}
|
|
39468
|
+
if (typeof this.shutdown === 'function') {
|
|
39469
|
+
await this.shutdown();
|
|
39470
|
+
}
|
|
39471
|
+
}
|
|
39472
|
+
catch (error) {
|
|
39473
|
+
logTelemetryFailure('trace_span_shutdown_failed', error);
|
|
39474
|
+
}
|
|
39475
|
+
}
|
|
39476
|
+
async flush() {
|
|
39477
|
+
// Default implementation: no-op
|
|
39478
|
+
}
|
|
39479
|
+
async shutdown() {
|
|
39480
|
+
// Default implementation: no-op
|
|
40027
39481
|
}
|
|
40028
|
-
return entries.length > 0 ? Object.fromEntries(entries) : undefined;
|
|
40029
39482
|
}
|
|
40030
39483
|
|
|
40031
|
-
|
|
39484
|
+
class NoopTraceSpan {
|
|
39485
|
+
setAttribute() { }
|
|
39486
|
+
recordException() { }
|
|
39487
|
+
setStatusError() { }
|
|
39488
|
+
}
|
|
39489
|
+
class NoopTraceSpanScope {
|
|
39490
|
+
constructor(span) {
|
|
39491
|
+
this.span = span;
|
|
39492
|
+
}
|
|
39493
|
+
enter() {
|
|
39494
|
+
return this.span;
|
|
39495
|
+
}
|
|
39496
|
+
exit() { }
|
|
39497
|
+
}
|
|
39498
|
+
class NoopTraceEmitter extends BaseTraceEmitter {
|
|
39499
|
+
startSpan(_name, _options) {
|
|
39500
|
+
void _options;
|
|
39501
|
+
return new NoopTraceSpanScope(new NoopTraceSpan());
|
|
39502
|
+
}
|
|
39503
|
+
}
|
|
39504
|
+
|
|
39505
|
+
const FACTORY_META$2 = {
|
|
39506
|
+
base: TRACE_EMITTER_FACTORY_BASE_TYPE,
|
|
39507
|
+
key: 'NoopTraceEmitter',
|
|
39508
|
+
};
|
|
39509
|
+
class NoopTraceEmitterFactory extends TraceEmitterFactory {
|
|
39510
|
+
constructor() {
|
|
39511
|
+
super(...arguments);
|
|
39512
|
+
this.type = 'NoopTraceEmitter';
|
|
39513
|
+
this.isDefault = true;
|
|
39514
|
+
this.priority = 100;
|
|
39515
|
+
}
|
|
39516
|
+
async create() {
|
|
39517
|
+
return new NoopTraceEmitter();
|
|
39518
|
+
}
|
|
39519
|
+
}
|
|
39520
|
+
|
|
39521
|
+
var noopTraceEmitterFactory = /*#__PURE__*/Object.freeze({
|
|
40032
39522
|
__proto__: null,
|
|
40033
|
-
|
|
39523
|
+
FACTORY_META: FACTORY_META$2,
|
|
39524
|
+
NoopTraceEmitterFactory: NoopTraceEmitterFactory,
|
|
39525
|
+
default: NoopTraceEmitterFactory
|
|
40034
39526
|
});
|
|
40035
39527
|
|
|
40036
|
-
|
|
40037
|
-
|
|
40038
|
-
|
|
40039
|
-
const
|
|
40040
|
-
const
|
|
40041
|
-
|
|
40042
|
-
|
|
40043
|
-
|
|
40044
|
-
|
|
40045
|
-
async function setupOtel(options) {
|
|
40046
|
-
const normalized = normalizeSetupOtelOptions(options);
|
|
40047
|
-
try {
|
|
40048
|
-
if (registeredOtel) {
|
|
40049
|
-
logger$5.debug('open_telemetry_reusing_provider', {
|
|
40050
|
-
service_name: normalized.serviceName,
|
|
40051
|
-
});
|
|
40052
|
-
return registeredOtel.control;
|
|
40053
|
-
}
|
|
40054
|
-
const [apiModule, resourcesModule, nodeModule, traceBaseModule] = await Promise.all([
|
|
40055
|
-
import(OTEL_API_SPEC),
|
|
40056
|
-
import(OTEL_RESOURCES_SPEC),
|
|
40057
|
-
import(OTEL_TRACE_NODE_SPEC),
|
|
40058
|
-
import(OTEL_TRACE_BASE_SPEC),
|
|
40059
|
-
]);
|
|
40060
|
-
const { trace } = apiModule;
|
|
40061
|
-
const { defaultResource, resourceFromAttributes } = resourcesModule;
|
|
40062
|
-
const { NodeTracerProvider } = nodeModule;
|
|
40063
|
-
const { BatchSpanProcessor, ConsoleSpanExporter, ParentBasedSampler, AlwaysOnSampler, AlwaysOffSampler, TraceIdRatioBasedSampler, } = traceBaseModule;
|
|
40064
|
-
const currentProvider = trace.getTracerProvider();
|
|
40065
|
-
if (currentProvider && currentProvider instanceof NodeTracerProvider) {
|
|
40066
|
-
return null;
|
|
40067
|
-
}
|
|
40068
|
-
if (currentProvider &&
|
|
40069
|
-
currentProvider.constructor?.name === 'NodeTracerProvider') {
|
|
40070
|
-
logger$5.debug('open_telemetry_existing_node_provider', {
|
|
40071
|
-
service_name: normalized.serviceName,
|
|
40072
|
-
});
|
|
40073
|
-
return null;
|
|
40074
|
-
}
|
|
40075
|
-
logger$5.debug('open_telemetry_initializing', {
|
|
40076
|
-
service_name: normalized.serviceName,
|
|
40077
|
-
endpoint: normalized.endpoint ?? null,
|
|
40078
|
-
environment: normalized.environment ?? null,
|
|
40079
|
-
sampler: normalized.sampler ?? null,
|
|
40080
|
-
headers_present: Boolean(normalized.headers && Object.keys(normalized.headers).length),
|
|
40081
|
-
});
|
|
40082
|
-
const sampler = resolveSampler(normalized.sampler, {
|
|
40083
|
-
ParentBasedSampler,
|
|
40084
|
-
AlwaysOnSampler,
|
|
40085
|
-
AlwaysOffSampler,
|
|
40086
|
-
TraceIdRatioBasedSampler,
|
|
40087
|
-
});
|
|
40088
|
-
const baseResource = defaultResource();
|
|
40089
|
-
const mergedResource = resourceFromAttributes({
|
|
40090
|
-
'service.name': normalized.serviceName,
|
|
40091
|
-
'service.instance.id': generateInstanceId(),
|
|
40092
|
-
'deployment.environment': normalized.environment ?? 'dev',
|
|
39528
|
+
let openTelemetryTraceEmitterModulePromise = null;
|
|
39529
|
+
let otelApiModulePromise = null;
|
|
39530
|
+
let otelSetupModulePromise = null;
|
|
39531
|
+
const logger$7 = getLogger('naylence.fame.telemetry.open_telemetry_trace_emitter_factory');
|
|
39532
|
+
const MISSING_OTEL_HELP_MESSAGE = 'Missing optional OpenTelemetry dependency. Install @opentelemetry/api (and related packages) to enable trace emission.';
|
|
39533
|
+
function getOpenTelemetryTraceEmitterModule() {
|
|
39534
|
+
if (!openTelemetryTraceEmitterModulePromise) {
|
|
39535
|
+
openTelemetryTraceEmitterModulePromise = safeImport(() => Promise.resolve().then(function () { return openTelemetryTraceEmitter; }), '@opentelemetry/api', {
|
|
39536
|
+
helpMessage: MISSING_OTEL_HELP_MESSAGE,
|
|
40093
39537
|
});
|
|
40094
|
-
|
|
40095
|
-
|
|
40096
|
-
|
|
40097
|
-
|
|
40098
|
-
|
|
40099
|
-
|
|
40100
|
-
|
|
39538
|
+
}
|
|
39539
|
+
return openTelemetryTraceEmitterModulePromise;
|
|
39540
|
+
}
|
|
39541
|
+
function getOtelApiModule() {
|
|
39542
|
+
if (!otelApiModulePromise) {
|
|
39543
|
+
otelApiModulePromise = safeImport(() => import('@opentelemetry/api'), '@opentelemetry/api', {
|
|
39544
|
+
helpMessage: MISSING_OTEL_HELP_MESSAGE,
|
|
40101
39545
|
});
|
|
40102
|
-
|
|
40103
|
-
|
|
40104
|
-
|
|
40105
|
-
|
|
39546
|
+
}
|
|
39547
|
+
return otelApiModulePromise;
|
|
39548
|
+
}
|
|
39549
|
+
function getOtelSetupModule() {
|
|
39550
|
+
if (!otelSetupModulePromise) {
|
|
39551
|
+
otelSetupModulePromise = safeImport(() => Promise.resolve().then(function () { return otelSetup; }), '@opentelemetry/api', {
|
|
39552
|
+
helpMessage: MISSING_OTEL_HELP_MESSAGE,
|
|
40106
39553
|
});
|
|
40107
|
-
|
|
40108
|
-
|
|
39554
|
+
}
|
|
39555
|
+
return otelSetupModulePromise;
|
|
39556
|
+
}
|
|
39557
|
+
const FACTORY_META$1 = {
|
|
39558
|
+
base: TRACE_EMITTER_FACTORY_BASE_TYPE,
|
|
39559
|
+
key: 'OpenTelemetryTraceEmitter',
|
|
39560
|
+
};
|
|
39561
|
+
class OpenTelemetryTraceEmitterFactory extends TraceEmitterFactory {
|
|
39562
|
+
constructor() {
|
|
39563
|
+
super(...arguments);
|
|
39564
|
+
this.type = 'OpenTelemetryTraceEmitter';
|
|
39565
|
+
}
|
|
39566
|
+
async create(config, ...factoryArgs) {
|
|
39567
|
+
const options = (factoryArgs[0] ??
|
|
39568
|
+
{});
|
|
39569
|
+
const normalized = normalizeConfig$1(config);
|
|
39570
|
+
const mergedHeaders = {
|
|
39571
|
+
...normalized.headers,
|
|
39572
|
+
...(options.headers ?? {}),
|
|
39573
|
+
};
|
|
39574
|
+
let authStrategy = null;
|
|
39575
|
+
if (normalized.auth) {
|
|
39576
|
+
authStrategy =
|
|
39577
|
+
await AuthInjectionStrategyFactory.createAuthInjectionStrategy(normalized.auth);
|
|
39578
|
+
try {
|
|
39579
|
+
await authStrategy.apply(mergedHeaders);
|
|
39580
|
+
logger$7.info('trace_emitter_auth_applied', {
|
|
39581
|
+
service_name: normalized.serviceName,
|
|
39582
|
+
});
|
|
39583
|
+
}
|
|
39584
|
+
catch (error) {
|
|
40109
39585
|
try {
|
|
40110
|
-
await
|
|
39586
|
+
await authStrategy.cleanup();
|
|
40111
39587
|
}
|
|
40112
|
-
catch
|
|
40113
|
-
|
|
40114
|
-
error: flushError instanceof Error
|
|
40115
|
-
? flushError.message
|
|
40116
|
-
: String(flushError),
|
|
40117
|
-
});
|
|
39588
|
+
catch {
|
|
39589
|
+
// Ignore cleanup errors while propagating original failure
|
|
40118
39590
|
}
|
|
40119
|
-
|
|
40120
|
-
|
|
39591
|
+
throw error;
|
|
39592
|
+
}
|
|
39593
|
+
}
|
|
39594
|
+
let lifecycle = null;
|
|
39595
|
+
try {
|
|
39596
|
+
const { setupOtel } = await getOtelSetupModule();
|
|
39597
|
+
lifecycle = await setupOtel({
|
|
39598
|
+
serviceName: normalized.serviceName,
|
|
39599
|
+
endpoint: normalized.endpoint,
|
|
39600
|
+
environment: normalized.environment,
|
|
39601
|
+
sampler: normalized.sampler,
|
|
39602
|
+
headers: Object.keys(mergedHeaders).length > 0 ? mergedHeaders : undefined,
|
|
39603
|
+
});
|
|
39604
|
+
logger$7.debug('trace_emitter_lifecycle_acquired', {
|
|
39605
|
+
service_name: normalized.serviceName,
|
|
39606
|
+
lifecycle_available: Boolean(lifecycle),
|
|
39607
|
+
});
|
|
39608
|
+
}
|
|
39609
|
+
catch (error) {
|
|
39610
|
+
if (authStrategy) {
|
|
40121
39611
|
try {
|
|
40122
|
-
await
|
|
40123
|
-
}
|
|
40124
|
-
catch (shutdownError) {
|
|
40125
|
-
logger$5.warning('open_telemetry_shutdown_failed', {
|
|
40126
|
-
error: shutdownError instanceof Error
|
|
40127
|
-
? shutdownError.message
|
|
40128
|
-
: String(shutdownError),
|
|
40129
|
-
});
|
|
39612
|
+
await authStrategy.cleanup();
|
|
40130
39613
|
}
|
|
40131
|
-
|
|
40132
|
-
|
|
39614
|
+
catch {
|
|
39615
|
+
// Ignore cleanup errors while propagating original failure
|
|
40133
39616
|
}
|
|
39617
|
+
}
|
|
39618
|
+
throw error;
|
|
39619
|
+
}
|
|
39620
|
+
const [{ OpenTelemetryTraceEmitter }, otelModule] = await Promise.all([
|
|
39621
|
+
getOpenTelemetryTraceEmitterModule(),
|
|
39622
|
+
getOtelApiModule(),
|
|
39623
|
+
]);
|
|
39624
|
+
const emitterOptions = {
|
|
39625
|
+
serviceName: normalized.serviceName,
|
|
39626
|
+
otelApi: {
|
|
39627
|
+
trace: otelModule.trace,
|
|
39628
|
+
SpanStatusCode: otelModule.SpanStatusCode,
|
|
40134
39629
|
},
|
|
40135
39630
|
};
|
|
40136
|
-
|
|
40137
|
-
|
|
40138
|
-
|
|
40139
|
-
|
|
40140
|
-
|
|
40141
|
-
|
|
40142
|
-
|
|
40143
|
-
|
|
40144
|
-
|
|
40145
|
-
|
|
40146
|
-
|
|
40147
|
-
|
|
39631
|
+
if (options.tracer) {
|
|
39632
|
+
emitterOptions.tracer = options.tracer;
|
|
39633
|
+
}
|
|
39634
|
+
if (lifecycle) {
|
|
39635
|
+
emitterOptions.lifecycle = lifecycle;
|
|
39636
|
+
}
|
|
39637
|
+
if (authStrategy) {
|
|
39638
|
+
emitterOptions.authStrategy = authStrategy;
|
|
39639
|
+
}
|
|
39640
|
+
try {
|
|
39641
|
+
const emitter = new OpenTelemetryTraceEmitter(emitterOptions);
|
|
39642
|
+
logger$7.debug('trace_emitter_created', {
|
|
39643
|
+
service_name: normalized.serviceName,
|
|
39644
|
+
has_lifecycle: Boolean(lifecycle),
|
|
39645
|
+
has_auth_strategy: Boolean(authStrategy),
|
|
39646
|
+
});
|
|
39647
|
+
return emitter;
|
|
39648
|
+
}
|
|
39649
|
+
catch (error) {
|
|
39650
|
+
if (authStrategy) {
|
|
39651
|
+
try {
|
|
39652
|
+
await authStrategy.cleanup();
|
|
39653
|
+
}
|
|
39654
|
+
catch {
|
|
39655
|
+
// Best effort cleanup
|
|
39656
|
+
}
|
|
39657
|
+
}
|
|
39658
|
+
throw error;
|
|
39659
|
+
}
|
|
40148
39660
|
}
|
|
40149
39661
|
}
|
|
40150
|
-
function
|
|
40151
|
-
|
|
40152
|
-
|
|
39662
|
+
function normalizeConfig$1(config) {
|
|
39663
|
+
if (!config) {
|
|
39664
|
+
return {
|
|
39665
|
+
serviceName: 'naylence-service',
|
|
39666
|
+
endpoint: null,
|
|
39667
|
+
environment: null,
|
|
39668
|
+
sampler: null,
|
|
39669
|
+
headers: {},
|
|
39670
|
+
auth: null,
|
|
39671
|
+
};
|
|
39672
|
+
}
|
|
39673
|
+
const candidate = config;
|
|
39674
|
+
const serviceName = extractString(pickFirst$2(candidate, ['serviceName', 'service_name'])) ??
|
|
40153
39675
|
'naylence-service';
|
|
40154
|
-
const endpoint =
|
|
40155
|
-
const environment =
|
|
39676
|
+
const endpoint = extractString(pickFirst$2(candidate, ['endpoint', 'otlpEndpoint', 'otlp_endpoint'])) ?? null;
|
|
39677
|
+
const environment = extractString(pickFirst$2(candidate, [
|
|
40156
39678
|
'environment',
|
|
40157
39679
|
'deploymentEnvironment',
|
|
40158
39680
|
'deployment_environment',
|
|
40159
39681
|
])) ?? null;
|
|
40160
|
-
const sampler =
|
|
40161
|
-
const
|
|
39682
|
+
const sampler = extractString(pickFirst$2(candidate, ['sampler', 'samplingStrategy', 'sampling_strategy'])) ?? null;
|
|
39683
|
+
const headersFromConfig = extractHeaders$1(pickFirst$2(candidate, ['headers', 'otlpHeaders', 'otlp_headers']));
|
|
39684
|
+
const authConfig = pickFirst$2(candidate, [
|
|
39685
|
+
'auth',
|
|
39686
|
+
]);
|
|
40162
39687
|
return {
|
|
40163
39688
|
serviceName,
|
|
40164
39689
|
endpoint,
|
|
40165
39690
|
environment,
|
|
40166
39691
|
sampler,
|
|
40167
|
-
headers:
|
|
39692
|
+
headers: headersFromConfig ?? {},
|
|
39693
|
+
auth: authConfig ?? null,
|
|
40168
39694
|
};
|
|
40169
39695
|
}
|
|
40170
|
-
function
|
|
39696
|
+
function extractString(value) {
|
|
39697
|
+
if (typeof value === 'string' && value.trim().length > 0) {
|
|
39698
|
+
return value;
|
|
39699
|
+
}
|
|
39700
|
+
return undefined;
|
|
39701
|
+
}
|
|
39702
|
+
function pickFirst$2(source, keys) {
|
|
40171
39703
|
for (const key of keys) {
|
|
40172
39704
|
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
40173
39705
|
const value = source[key];
|
|
@@ -40178,16 +39710,7 @@ function pickFirst(source, keys) {
|
|
|
40178
39710
|
}
|
|
40179
39711
|
return undefined;
|
|
40180
39712
|
}
|
|
40181
|
-
function
|
|
40182
|
-
if (typeof value === 'string') {
|
|
40183
|
-
const trimmed = value.trim();
|
|
40184
|
-
if (trimmed.length > 0) {
|
|
40185
|
-
return trimmed;
|
|
40186
|
-
}
|
|
40187
|
-
}
|
|
40188
|
-
return undefined;
|
|
40189
|
-
}
|
|
40190
|
-
function extractHeaders(value) {
|
|
39713
|
+
function extractHeaders$1(value) {
|
|
40191
39714
|
if (!value || typeof value !== 'object') {
|
|
40192
39715
|
return null;
|
|
40193
39716
|
}
|
|
@@ -40199,76 +39722,145 @@ function extractHeaders(value) {
|
|
|
40199
39722
|
}
|
|
40200
39723
|
return Object.keys(headers).length > 0 ? headers : null;
|
|
40201
39724
|
}
|
|
40202
|
-
|
|
40203
|
-
|
|
40204
|
-
|
|
40205
|
-
|
|
40206
|
-
|
|
40207
|
-
|
|
39725
|
+
|
|
39726
|
+
var openTelemetryTraceEmitterFactory = /*#__PURE__*/Object.freeze({
|
|
39727
|
+
__proto__: null,
|
|
39728
|
+
FACTORY_META: FACTORY_META$1,
|
|
39729
|
+
OpenTelemetryTraceEmitterFactory: OpenTelemetryTraceEmitterFactory,
|
|
39730
|
+
default: OpenTelemetryTraceEmitterFactory
|
|
39731
|
+
});
|
|
39732
|
+
|
|
39733
|
+
const logger$6 = getLogger('naylence.fame.telemetry.trace_emitter_profile_factory');
|
|
39734
|
+
const PROFILE_NAME_NOOP = 'noop';
|
|
39735
|
+
const PROFILE_NAME_OPEN_TELEMETRY = 'open-telemetry';
|
|
39736
|
+
const ENV_VAR_TELEMETRY_SERVICE_NAME = 'FAME_TELEMETRY_SERVICE_NAME';
|
|
39737
|
+
const NOOP_PROFILE = {
|
|
39738
|
+
type: 'NoopTraceEmitter',
|
|
39739
|
+
};
|
|
39740
|
+
const OPEN_TELEMETRY_PROFILE = {
|
|
39741
|
+
type: 'OpenTelemetryTraceEmitter',
|
|
39742
|
+
serviceName: factory.Expressions.env(ENV_VAR_TELEMETRY_SERVICE_NAME, 'naylence-service'),
|
|
39743
|
+
headers: {},
|
|
39744
|
+
};
|
|
39745
|
+
const PROFILE_MAP = {
|
|
39746
|
+
[PROFILE_NAME_NOOP]: NOOP_PROFILE,
|
|
39747
|
+
[PROFILE_NAME_OPEN_TELEMETRY]: OPEN_TELEMETRY_PROFILE,
|
|
39748
|
+
};
|
|
39749
|
+
const FACTORY_META = {
|
|
39750
|
+
base: TRACE_EMITTER_FACTORY_BASE_TYPE,
|
|
39751
|
+
key: 'TraceEmitterProfile',
|
|
39752
|
+
};
|
|
39753
|
+
class TraceEmitterProfileFactory extends TraceEmitterFactory {
|
|
39754
|
+
constructor() {
|
|
39755
|
+
super(...arguments);
|
|
39756
|
+
this.type = 'TraceEmitterProfile';
|
|
40208
39757
|
}
|
|
40209
|
-
|
|
40210
|
-
|
|
39758
|
+
async create(config, ...factoryArgs) {
|
|
39759
|
+
const normalized = normalizeTraceEmitterProfileConfig(config);
|
|
39760
|
+
const profileConfig = resolveProfileConfig(normalized.profile);
|
|
39761
|
+
logger$6.debug('enabling_trace_emitter_profile', {
|
|
39762
|
+
profile: normalized.profile,
|
|
39763
|
+
});
|
|
39764
|
+
const traceEmitter = await TraceEmitterFactory.createTraceEmitter(profileConfig, {
|
|
39765
|
+
factoryArgs,
|
|
39766
|
+
});
|
|
39767
|
+
if (!traceEmitter) {
|
|
39768
|
+
throw new Error(`Failed to instantiate trace emitter profile: ${normalized.profile}`);
|
|
39769
|
+
}
|
|
39770
|
+
return traceEmitter;
|
|
40211
39771
|
}
|
|
40212
|
-
const random = Math.random().toString(16).slice(2);
|
|
40213
|
-
return random.padEnd(32, '0').slice(0, 32);
|
|
40214
39772
|
}
|
|
40215
|
-
function
|
|
40216
|
-
|
|
40217
|
-
|
|
40218
|
-
if (normalized === 'always_off') {
|
|
40219
|
-
base = new samplers.AlwaysOffSampler();
|
|
39773
|
+
function normalizeTraceEmitterProfileConfig(config) {
|
|
39774
|
+
if (!config) {
|
|
39775
|
+
return { profile: PROFILE_NAME_NOOP };
|
|
40220
39776
|
}
|
|
40221
|
-
|
|
40222
|
-
|
|
40223
|
-
|
|
39777
|
+
const candidate = config;
|
|
39778
|
+
const profileValue = resolveProfileName(candidate);
|
|
39779
|
+
const canonicalProfile = canonicalizeProfileName(profileValue);
|
|
39780
|
+
candidate.profile = canonicalProfile;
|
|
39781
|
+
return { profile: canonicalProfile };
|
|
39782
|
+
}
|
|
39783
|
+
function resolveProfileName(candidate) {
|
|
39784
|
+
const direct = coerceProfileString(candidate.profile);
|
|
39785
|
+
if (direct) {
|
|
39786
|
+
return direct;
|
|
40224
39787
|
}
|
|
40225
|
-
|
|
40226
|
-
|
|
40227
|
-
const
|
|
40228
|
-
|
|
40229
|
-
|
|
40230
|
-
|
|
39788
|
+
const legacyKeys = ['profile_name', 'profileName'];
|
|
39789
|
+
for (const legacyKey of legacyKeys) {
|
|
39790
|
+
const legacyValue = coerceProfileString(candidate[legacyKey]);
|
|
39791
|
+
if (legacyValue) {
|
|
39792
|
+
return legacyValue;
|
|
39793
|
+
}
|
|
40231
39794
|
}
|
|
40232
|
-
|
|
40233
|
-
|
|
39795
|
+
return PROFILE_NAME_NOOP;
|
|
39796
|
+
}
|
|
39797
|
+
function coerceProfileString(value) {
|
|
39798
|
+
if (typeof value !== 'string') {
|
|
39799
|
+
return null;
|
|
40234
39800
|
}
|
|
40235
|
-
|
|
39801
|
+
const trimmed = value.trim();
|
|
39802
|
+
return trimmed.length > 0 ? trimmed : null;
|
|
40236
39803
|
}
|
|
40237
|
-
|
|
40238
|
-
|
|
40239
|
-
|
|
40240
|
-
|
|
40241
|
-
|
|
40242
|
-
|
|
40243
|
-
|
|
40244
|
-
|
|
40245
|
-
|
|
40246
|
-
|
|
40247
|
-
|
|
40248
|
-
|
|
40249
|
-
|
|
40250
|
-
|
|
40251
|
-
|
|
40252
|
-
|
|
40253
|
-
return new OTLPTraceExporter(exporterOptions);
|
|
40254
|
-
}
|
|
40255
|
-
}
|
|
40256
|
-
catch (error) {
|
|
40257
|
-
logger$5.error('open_telemetry_exporter_not_available', {
|
|
40258
|
-
error: error instanceof Error ? error.message : String(error),
|
|
40259
|
-
});
|
|
40260
|
-
}
|
|
39804
|
+
const PROFILE_ALIASES = {
|
|
39805
|
+
noop: PROFILE_NAME_NOOP,
|
|
39806
|
+
'no-op': PROFILE_NAME_NOOP,
|
|
39807
|
+
no_op: PROFILE_NAME_NOOP,
|
|
39808
|
+
'open-telemetry': PROFILE_NAME_OPEN_TELEMETRY,
|
|
39809
|
+
open_telemetry: PROFILE_NAME_OPEN_TELEMETRY,
|
|
39810
|
+
opentelemetry: PROFILE_NAME_OPEN_TELEMETRY,
|
|
39811
|
+
};
|
|
39812
|
+
function canonicalizeProfileName(value) {
|
|
39813
|
+
const normalized = value.replace(/[\s_]+/g, '-').toLowerCase();
|
|
39814
|
+
return PROFILE_ALIASES[normalized] ?? normalized;
|
|
39815
|
+
}
|
|
39816
|
+
function resolveProfileConfig(profileName) {
|
|
39817
|
+
const profile = PROFILE_MAP[profileName];
|
|
39818
|
+
if (!profile) {
|
|
39819
|
+
throw new Error(`Unknown trace emitter profile: ${profileName}`);
|
|
40261
39820
|
}
|
|
40262
|
-
|
|
40263
|
-
|
|
39821
|
+
return deepClone(profile);
|
|
39822
|
+
}
|
|
39823
|
+
function deepClone(value) {
|
|
39824
|
+
return JSON.parse(JSON.stringify(value));
|
|
40264
39825
|
}
|
|
40265
39826
|
|
|
40266
|
-
var
|
|
39827
|
+
var traceEmitterProfileFactory = /*#__PURE__*/Object.freeze({
|
|
40267
39828
|
__proto__: null,
|
|
40268
|
-
|
|
39829
|
+
FACTORY_META: FACTORY_META,
|
|
39830
|
+
PROFILE_NAME_NOOP: PROFILE_NAME_NOOP,
|
|
39831
|
+
PROFILE_NAME_OPEN_TELEMETRY: PROFILE_NAME_OPEN_TELEMETRY,
|
|
39832
|
+
TraceEmitterProfileFactory: TraceEmitterProfileFactory,
|
|
39833
|
+
default: TraceEmitterProfileFactory
|
|
40269
39834
|
});
|
|
40270
39835
|
|
|
40271
|
-
|
|
39836
|
+
let initialized = false;
|
|
39837
|
+
const runtimePlugin = {
|
|
39838
|
+
name: 'naylence:runtime',
|
|
39839
|
+
version: VERSION,
|
|
39840
|
+
async register() {
|
|
39841
|
+
// console.log('[naylence:runtime] register() called, initialized=', initialized);
|
|
39842
|
+
if (initialized) {
|
|
39843
|
+
// console.log('[naylence:runtime] already initialized, skipping');
|
|
39844
|
+
return;
|
|
39845
|
+
}
|
|
39846
|
+
initialized = true;
|
|
39847
|
+
// console.log('[naylence:runtime] registering runtime factories...');
|
|
39848
|
+
// Register factories from manifest
|
|
39849
|
+
await registerRuntimeFactories();
|
|
39850
|
+
// Import modules with side-effect registrations (not in manifest)
|
|
39851
|
+
await Promise.resolve().then(function () { return websocketTransportProvisioner; });
|
|
39852
|
+
// console.log('[naylence:runtime] runtime factories registered');
|
|
39853
|
+
},
|
|
39854
|
+
};
|
|
39855
|
+
const RUNTIME_PLUGIN_SPECIFIER = runtimePlugin.name;
|
|
39856
|
+
|
|
39857
|
+
var plugin = /*#__PURE__*/Object.freeze({
|
|
39858
|
+
__proto__: null,
|
|
39859
|
+
RUNTIME_PLUGIN_SPECIFIER: RUNTIME_PLUGIN_SPECIFIER,
|
|
39860
|
+
default: runtimePlugin
|
|
39861
|
+
});
|
|
39862
|
+
|
|
39863
|
+
const logger$5 = getLogger('naylence.fame.security.auth.default_authorizer');
|
|
40272
39864
|
function decodeCredentials$1(credentials) {
|
|
40273
39865
|
if (typeof TextDecoder !== 'undefined') {
|
|
40274
39866
|
return new TextDecoder().decode(credentials);
|
|
@@ -40402,7 +39994,7 @@ class DefaultAuthorizer {
|
|
|
40402
39994
|
});
|
|
40403
39995
|
}
|
|
40404
39996
|
catch (error) {
|
|
40405
|
-
logger$
|
|
39997
|
+
logger$5.warning('token_verification_failed', {
|
|
40406
39998
|
error: error instanceof Error ? error.message : String(error),
|
|
40407
39999
|
});
|
|
40408
40000
|
return undefined;
|
|
@@ -40493,7 +40085,7 @@ var defaultAuthorizer = /*#__PURE__*/Object.freeze({
|
|
|
40493
40085
|
DefaultAuthorizer: DefaultAuthorizer
|
|
40494
40086
|
});
|
|
40495
40087
|
|
|
40496
|
-
const logger$
|
|
40088
|
+
const logger$4 = getLogger('naylence.fame.security.auth.jwks_jwt_token_verifier');
|
|
40497
40089
|
const DEFAULT_ALGORITHMS = ['RS256', 'ES256', 'EdDSA'];
|
|
40498
40090
|
function normalizeOptions$5(options) {
|
|
40499
40091
|
if (!options || typeof options !== 'object') {
|
|
@@ -40543,7 +40135,7 @@ class JWKSJWTTokenVerifier {
|
|
|
40543
40135
|
this.algorithms = (normalized.algorithms && normalized.algorithms.length > 0
|
|
40544
40136
|
? normalized.algorithms
|
|
40545
40137
|
: Array.from(DEFAULT_ALGORITHMS)).map((alg) => alg.toString().trim());
|
|
40546
|
-
logger$
|
|
40138
|
+
logger$4.debug('jwks_jwt_token_verifier_initialized', {
|
|
40547
40139
|
issuer: this.issuer,
|
|
40548
40140
|
jwks_url: this.jwksUrl.toString(),
|
|
40549
40141
|
cache_ttl_ms: this.cacheTtlMs,
|
|
@@ -40565,7 +40157,7 @@ class JWKSJWTTokenVerifier {
|
|
|
40565
40157
|
return buildAuthorizationContext$1(payload, protectedHeader?.kid);
|
|
40566
40158
|
}
|
|
40567
40159
|
catch (error) {
|
|
40568
|
-
logger$
|
|
40160
|
+
logger$4.warning('jwks_jwt_token_verifier_failed', {
|
|
40569
40161
|
error: error instanceof Error ? error.message : String(error),
|
|
40570
40162
|
});
|
|
40571
40163
|
throw this.normalizeJoseError(error);
|
|
@@ -40616,7 +40208,7 @@ var jwksJwtTokenVerifier = /*#__PURE__*/Object.freeze({
|
|
|
40616
40208
|
JWKSJWTTokenVerifier: JWKSJWTTokenVerifier
|
|
40617
40209
|
});
|
|
40618
40210
|
|
|
40619
|
-
const logger$
|
|
40211
|
+
const logger$3 = getLogger('naylence.fame.security.auth.oauth2_authorizer');
|
|
40620
40212
|
function normalizeOptions$4(raw) {
|
|
40621
40213
|
const camel = raw;
|
|
40622
40214
|
const snake = raw;
|
|
@@ -40681,12 +40273,12 @@ class OAuth2Authorizer {
|
|
|
40681
40273
|
async authenticate(credentials) {
|
|
40682
40274
|
const token = this.normalizeBearerToken(credentials);
|
|
40683
40275
|
if (!token) {
|
|
40684
|
-
logger$
|
|
40276
|
+
logger$3.debug('oauth2_authenticate_missing_token');
|
|
40685
40277
|
return undefined;
|
|
40686
40278
|
}
|
|
40687
40279
|
try {
|
|
40688
40280
|
const expectedAudience = this.audience ?? this.node?.physicalPath;
|
|
40689
|
-
logger$
|
|
40281
|
+
logger$3.debug('oauth2_authenticate_start', {
|
|
40690
40282
|
expected_audience: expectedAudience,
|
|
40691
40283
|
});
|
|
40692
40284
|
const context = expectedAudience !== undefined
|
|
@@ -40698,7 +40290,7 @@ class OAuth2Authorizer {
|
|
|
40698
40290
|
if (this.requireScope &&
|
|
40699
40291
|
this.requiredScopes.size > 0 &&
|
|
40700
40292
|
!this.hasRequiredScope(grantedScopes)) {
|
|
40701
|
-
logger$
|
|
40293
|
+
logger$3.warning('oauth2_token_missing_required_scope', {
|
|
40702
40294
|
required_scopes: Array.from(this.requiredScopes),
|
|
40703
40295
|
token_scopes: Array.from(scopes),
|
|
40704
40296
|
});
|
|
@@ -40712,13 +40304,13 @@ class OAuth2Authorizer {
|
|
|
40712
40304
|
grantedScopes,
|
|
40713
40305
|
authMethod: context.authMethod ?? 'oauth2_jwt',
|
|
40714
40306
|
});
|
|
40715
|
-
logger$
|
|
40307
|
+
logger$3.debug('oauth2_authenticate_success', {
|
|
40716
40308
|
granted_scopes: Array.from(grantedScopes),
|
|
40717
40309
|
});
|
|
40718
40310
|
return normalized;
|
|
40719
40311
|
}
|
|
40720
40312
|
catch (error) {
|
|
40721
|
-
logger$
|
|
40313
|
+
logger$3.warning('oauth2_token_verification_failed', {
|
|
40722
40314
|
error: error instanceof Error ? error.message : String(error),
|
|
40723
40315
|
});
|
|
40724
40316
|
return undefined;
|
|
@@ -40760,7 +40352,7 @@ class OAuth2Authorizer {
|
|
|
40760
40352
|
instance_id: node.instanceId ?? null,
|
|
40761
40353
|
capabilities: Array.from(this.requiredScopes),
|
|
40762
40354
|
});
|
|
40763
|
-
logger$
|
|
40355
|
+
logger$3.debug('reverse_authorization_token_generated', {
|
|
40764
40356
|
node_id: node.id,
|
|
40765
40357
|
expires_at: expiresAt.toISOString(),
|
|
40766
40358
|
capabilities: Array.from(this.requiredScopes),
|
|
@@ -40777,7 +40369,7 @@ class OAuth2Authorizer {
|
|
|
40777
40369
|
return result;
|
|
40778
40370
|
}
|
|
40779
40371
|
catch (error) {
|
|
40780
|
-
logger$
|
|
40372
|
+
logger$3.warning('failed_to_generate_reverse_auth_token', {
|
|
40781
40373
|
node_id: node.id,
|
|
40782
40374
|
error: error instanceof Error ? error.message : String(error),
|
|
40783
40375
|
});
|
|
@@ -40794,7 +40386,7 @@ class OAuth2Authorizer {
|
|
|
40794
40386
|
if (this.requireScope &&
|
|
40795
40387
|
this.requiredScopes.size > 0 &&
|
|
40796
40388
|
!this.hasRequiredScope(grantedScopes)) {
|
|
40797
|
-
logger$
|
|
40389
|
+
logger$3.warning('oauth2_attach_missing_required_scope', {
|
|
40798
40390
|
required_scopes: Array.from(this.requiredScopes),
|
|
40799
40391
|
token_scopes: Array.from(scopes),
|
|
40800
40392
|
});
|
|
@@ -40884,7 +40476,7 @@ var oauth2Authorizer = /*#__PURE__*/Object.freeze({
|
|
|
40884
40476
|
OAuth2Authorizer: OAuth2Authorizer
|
|
40885
40477
|
});
|
|
40886
40478
|
|
|
40887
|
-
const logger$
|
|
40479
|
+
const logger$2 = getLogger('naylence.fame.security.auth.oauth2_client_credentials_token_provider');
|
|
40888
40480
|
function normalizeOptions$3(raw) {
|
|
40889
40481
|
const camel = raw;
|
|
40890
40482
|
const snake = raw;
|
|
@@ -40950,7 +40542,7 @@ class OAuth2ClientCredentialsTokenProvider {
|
|
|
40950
40542
|
}
|
|
40951
40543
|
async getToken() {
|
|
40952
40544
|
if (this.cachedToken && this.isTokenFresh(this.cachedToken)) {
|
|
40953
|
-
logger$
|
|
40545
|
+
logger$2.debug('using_cached_oauth2_token', {
|
|
40954
40546
|
token_url: this.options.tokenUrl,
|
|
40955
40547
|
});
|
|
40956
40548
|
return { ...this.cachedToken };
|
|
@@ -41005,7 +40597,7 @@ class OAuth2ClientCredentialsTokenProvider {
|
|
|
41005
40597
|
}
|
|
41006
40598
|
const expiresInSeconds = this.resolveExpiresIn(payload);
|
|
41007
40599
|
const expiresAt = Date.now() + expiresInSeconds * 1000;
|
|
41008
|
-
logger$
|
|
40600
|
+
logger$2.debug('oauth2_token_fetched', {
|
|
41009
40601
|
token_url: this.options.tokenUrl,
|
|
41010
40602
|
scopes: this.options.scopes,
|
|
41011
40603
|
audience: this.options.audience,
|
|
@@ -41040,7 +40632,7 @@ var oauth2ClientCredentialsTokenProvider = /*#__PURE__*/Object.freeze({
|
|
|
41040
40632
|
OAuth2ClientCredentialsTokenProvider: OAuth2ClientCredentialsTokenProvider
|
|
41041
40633
|
});
|
|
41042
40634
|
|
|
41043
|
-
const logger = getLogger('naylence.fame.security.auth.oauth2_pkce_token_provider');
|
|
40635
|
+
const logger$1 = getLogger('naylence.fame.security.auth.oauth2_pkce_token_provider');
|
|
41044
40636
|
const DEFAULT_SCOPES = [];
|
|
41045
40637
|
const DEFAULT_CLOCK_SKEW_SECONDS = 30;
|
|
41046
40638
|
const DEFAULT_CODE_VERIFIER_LENGTH = 48; // bytes before base64url encoding
|
|
@@ -41215,7 +40807,7 @@ function readPendingAuthorization(clientId) {
|
|
|
41215
40807
|
return parsed;
|
|
41216
40808
|
}
|
|
41217
40809
|
catch (error) {
|
|
41218
|
-
logger.debug('pkce_storage_read_failed', {
|
|
40810
|
+
logger$1.debug('pkce_storage_read_failed', {
|
|
41219
40811
|
error: error instanceof Error ? error.message : String(error),
|
|
41220
40812
|
});
|
|
41221
40813
|
return null;
|
|
@@ -41234,7 +40826,7 @@ function writePendingAuthorization(clientId, pending) {
|
|
|
41234
40826
|
window.sessionStorage.setItem(key, JSON.stringify(pending));
|
|
41235
40827
|
}
|
|
41236
40828
|
catch (error) {
|
|
41237
|
-
logger.debug('pkce_storage_write_failed', {
|
|
40829
|
+
logger$1.debug('pkce_storage_write_failed', {
|
|
41238
40830
|
error: error instanceof Error ? error.message : String(error),
|
|
41239
40831
|
});
|
|
41240
40832
|
}
|
|
@@ -41280,7 +40872,7 @@ function clearOAuthParamsFromUrl(url) {
|
|
|
41280
40872
|
window.history.replaceState(window.history.state, '', finalUrl);
|
|
41281
40873
|
}
|
|
41282
40874
|
catch (error) {
|
|
41283
|
-
logger.debug('pkce_replace_state_failed', {
|
|
40875
|
+
logger$1.debug('pkce_replace_state_failed', {
|
|
41284
40876
|
error: error instanceof Error ? error.message : String(error),
|
|
41285
40877
|
});
|
|
41286
40878
|
}
|
|
@@ -41321,7 +40913,7 @@ class OAuth2PkceTokenProvider {
|
|
|
41321
40913
|
if (persisted) {
|
|
41322
40914
|
if (this.isTokenCompatible(persisted.scopes, persisted.audience)) {
|
|
41323
40915
|
if (!persisted.expiresAt || this.isTokenFresh(persisted)) {
|
|
41324
|
-
logger.debug('using_persisted_oauth2_pkce_token', {
|
|
40916
|
+
logger$1.debug('using_persisted_oauth2_pkce_token', {
|
|
41325
40917
|
authorize_url: this.options.authorizeUrl,
|
|
41326
40918
|
});
|
|
41327
40919
|
const cached = {
|
|
@@ -41342,7 +40934,7 @@ class OAuth2PkceTokenProvider {
|
|
|
41342
40934
|
}
|
|
41343
40935
|
}
|
|
41344
40936
|
if (this.cachedToken && this.isTokenFresh(this.cachedToken)) {
|
|
41345
|
-
logger.debug('using_cached_oauth2_pkce_token', {
|
|
40937
|
+
logger$1.debug('using_cached_oauth2_pkce_token', {
|
|
41346
40938
|
authorize_url: this.options.authorizeUrl,
|
|
41347
40939
|
});
|
|
41348
40940
|
return { ...this.cachedToken };
|
|
@@ -41365,7 +40957,7 @@ class OAuth2PkceTokenProvider {
|
|
|
41365
40957
|
async beginBrowserAuthorization() {
|
|
41366
40958
|
const existing = readPendingAuthorization(this.options.clientId);
|
|
41367
40959
|
if (existing) {
|
|
41368
|
-
logger.debug('pkce_redirect_in_progress', {
|
|
40960
|
+
logger$1.debug('pkce_redirect_in_progress', {
|
|
41369
40961
|
authorize_url: this.options.authorizeUrl,
|
|
41370
40962
|
});
|
|
41371
40963
|
this.navigate(existing.authorizeUrl);
|
|
@@ -41395,7 +40987,7 @@ class OAuth2PkceTokenProvider {
|
|
|
41395
40987
|
};
|
|
41396
40988
|
writePersistedToken(this.options.clientId, null);
|
|
41397
40989
|
writePendingAuthorization(this.options.clientId, pending);
|
|
41398
|
-
logger.debug('pkce_redirect_start', {
|
|
40990
|
+
logger$1.debug('pkce_redirect_start', {
|
|
41399
40991
|
authorize_url: this.options.authorizeUrl,
|
|
41400
40992
|
redirect_uri: this.options.redirectUri,
|
|
41401
40993
|
});
|
|
@@ -41409,7 +41001,7 @@ class OAuth2PkceTokenProvider {
|
|
|
41409
41001
|
window.location.assign(url);
|
|
41410
41002
|
}
|
|
41411
41003
|
catch (error) {
|
|
41412
|
-
logger.error('pkce_navigation_failed', {
|
|
41004
|
+
logger$1.error('pkce_navigation_failed', {
|
|
41413
41005
|
authorize_url: url,
|
|
41414
41006
|
error: error instanceof Error ? error.message : String(error),
|
|
41415
41007
|
});
|
|
@@ -41553,7 +41145,7 @@ class OAuth2PkceTokenProvider {
|
|
|
41553
41145
|
value: accessToken,
|
|
41554
41146
|
expiresAt: Date.now() + expiresInSeconds * 1000,
|
|
41555
41147
|
};
|
|
41556
|
-
logger.debug('oauth2_pkce_token_fetched', {
|
|
41148
|
+
logger$1.debug('oauth2_pkce_token_fetched', {
|
|
41557
41149
|
authorize_url: this.options.authorizeUrl,
|
|
41558
41150
|
token_url: this.options.tokenUrl,
|
|
41559
41151
|
expires_in: expiresInSeconds,
|
|
@@ -41569,7 +41161,7 @@ class OAuth2PkceTokenProvider {
|
|
|
41569
41161
|
clearToken() {
|
|
41570
41162
|
this.cachedToken = undefined;
|
|
41571
41163
|
writePersistedToken(this.options.clientId, null);
|
|
41572
|
-
logger.debug('oauth2_pkce_token_cleared', {
|
|
41164
|
+
logger$1.debug('oauth2_pkce_token_cleared', {
|
|
41573
41165
|
authorize_url: this.options.authorizeUrl,
|
|
41574
41166
|
});
|
|
41575
41167
|
}
|
|
@@ -41966,6 +41558,543 @@ var eddsaEnvelopeVerifier = /*#__PURE__*/Object.freeze({
|
|
|
41966
41558
|
EdDSAEnvelopeVerifier: EdDSAEnvelopeVerifier
|
|
41967
41559
|
});
|
|
41968
41560
|
|
|
41561
|
+
let currentTraceId = null;
|
|
41562
|
+
let currentSpanId = null;
|
|
41563
|
+
function getOtelTraceId() {
|
|
41564
|
+
return currentTraceId;
|
|
41565
|
+
}
|
|
41566
|
+
function getOtelSpanId() {
|
|
41567
|
+
return currentSpanId;
|
|
41568
|
+
}
|
|
41569
|
+
function setOtelTraceId(traceId) {
|
|
41570
|
+
const previous = currentTraceId;
|
|
41571
|
+
currentTraceId = traceId;
|
|
41572
|
+
return previous;
|
|
41573
|
+
}
|
|
41574
|
+
function setOtelSpanId(spanId) {
|
|
41575
|
+
const previous = currentSpanId;
|
|
41576
|
+
currentSpanId = spanId;
|
|
41577
|
+
return previous;
|
|
41578
|
+
}
|
|
41579
|
+
function resetOtelTraceId(previous) {
|
|
41580
|
+
currentTraceId = previous;
|
|
41581
|
+
}
|
|
41582
|
+
function resetOtelSpanId(previous) {
|
|
41583
|
+
currentSpanId = previous;
|
|
41584
|
+
}
|
|
41585
|
+
|
|
41586
|
+
class OpenTelemetryTraceSpan {
|
|
41587
|
+
constructor(span, api) {
|
|
41588
|
+
this.span = span;
|
|
41589
|
+
this.api = api;
|
|
41590
|
+
}
|
|
41591
|
+
setAttribute(key, value) {
|
|
41592
|
+
try {
|
|
41593
|
+
this.span.setAttribute(key, normalizeAttributeValue(value));
|
|
41594
|
+
}
|
|
41595
|
+
catch {
|
|
41596
|
+
// Ignore telemetry attribute errors
|
|
41597
|
+
}
|
|
41598
|
+
}
|
|
41599
|
+
recordException(error) {
|
|
41600
|
+
try {
|
|
41601
|
+
if (error instanceof Error) {
|
|
41602
|
+
this.span.recordException(error);
|
|
41603
|
+
}
|
|
41604
|
+
else {
|
|
41605
|
+
this.span.recordException(new Error(String(error)));
|
|
41606
|
+
}
|
|
41607
|
+
}
|
|
41608
|
+
catch {
|
|
41609
|
+
// Ignore telemetry recording errors
|
|
41610
|
+
}
|
|
41611
|
+
}
|
|
41612
|
+
setStatusError(description) {
|
|
41613
|
+
try {
|
|
41614
|
+
const status = {
|
|
41615
|
+
code: this.api.SpanStatusCode.ERROR,
|
|
41616
|
+
};
|
|
41617
|
+
if (description !== undefined) {
|
|
41618
|
+
status.message = description;
|
|
41619
|
+
}
|
|
41620
|
+
this.span.setStatus(status);
|
|
41621
|
+
}
|
|
41622
|
+
catch {
|
|
41623
|
+
// Ignore telemetry status errors
|
|
41624
|
+
}
|
|
41625
|
+
}
|
|
41626
|
+
}
|
|
41627
|
+
class OpenTelemetrySpanScope {
|
|
41628
|
+
constructor(span, api) {
|
|
41629
|
+
this.span = span;
|
|
41630
|
+
this.entered = false;
|
|
41631
|
+
this.wrapper = new OpenTelemetryTraceSpan(span, api);
|
|
41632
|
+
}
|
|
41633
|
+
enter() {
|
|
41634
|
+
if (!this.entered) {
|
|
41635
|
+
this.entered = true;
|
|
41636
|
+
const spanContext = this.span.spanContext();
|
|
41637
|
+
this.traceToken = setOtelTraceId(spanContext?.traceId ?? null);
|
|
41638
|
+
this.spanToken = setOtelSpanId(spanContext?.spanId ?? null);
|
|
41639
|
+
}
|
|
41640
|
+
return this.wrapper;
|
|
41641
|
+
}
|
|
41642
|
+
exit() {
|
|
41643
|
+
try {
|
|
41644
|
+
this.span.end();
|
|
41645
|
+
}
|
|
41646
|
+
catch {
|
|
41647
|
+
// Ignore span termination errors
|
|
41648
|
+
}
|
|
41649
|
+
finally {
|
|
41650
|
+
if (this.traceToken !== undefined) {
|
|
41651
|
+
resetOtelTraceId(this.traceToken);
|
|
41652
|
+
this.traceToken = undefined;
|
|
41653
|
+
}
|
|
41654
|
+
if (this.spanToken !== undefined) {
|
|
41655
|
+
resetOtelSpanId(this.spanToken);
|
|
41656
|
+
this.spanToken = undefined;
|
|
41657
|
+
}
|
|
41658
|
+
}
|
|
41659
|
+
}
|
|
41660
|
+
}
|
|
41661
|
+
class OpenTelemetryTraceEmitter extends BaseTraceEmitter {
|
|
41662
|
+
constructor(options) {
|
|
41663
|
+
super();
|
|
41664
|
+
this.shutdownInvoked = false;
|
|
41665
|
+
const normalized = normalizeOpenTelemetryTraceEmitterOptions(options);
|
|
41666
|
+
this.otelApi = normalized.otelApi;
|
|
41667
|
+
this.tracer =
|
|
41668
|
+
normalized.tracer ?? this.otelApi.trace.getTracer(normalized.serviceName);
|
|
41669
|
+
this.lifecycle = normalized.lifecycle ?? null;
|
|
41670
|
+
this.authStrategy = normalized.authStrategy ?? null;
|
|
41671
|
+
}
|
|
41672
|
+
startSpan(name, options) {
|
|
41673
|
+
const attributes = normalizeAttributes(options?.attributes);
|
|
41674
|
+
const spanOptions = {};
|
|
41675
|
+
if (attributes) {
|
|
41676
|
+
spanOptions.attributes = attributes;
|
|
41677
|
+
}
|
|
41678
|
+
if (options?.links) {
|
|
41679
|
+
spanOptions.links = options.links;
|
|
41680
|
+
}
|
|
41681
|
+
const span = this.tracer.startSpan(name, spanOptions);
|
|
41682
|
+
const envelopeTraceId = options?.attributes?.['env.trace_id'];
|
|
41683
|
+
if (typeof envelopeTraceId === 'string') {
|
|
41684
|
+
this.applyEnvelopeTraceId(span, envelopeTraceId);
|
|
41685
|
+
}
|
|
41686
|
+
return new OpenTelemetrySpanScope(span, this.otelApi);
|
|
41687
|
+
}
|
|
41688
|
+
async flush() {
|
|
41689
|
+
if (this.lifecycle?.forceFlush) {
|
|
41690
|
+
try {
|
|
41691
|
+
await this.lifecycle.forceFlush();
|
|
41692
|
+
return;
|
|
41693
|
+
}
|
|
41694
|
+
catch {
|
|
41695
|
+
// fall through to global flush fallback
|
|
41696
|
+
}
|
|
41697
|
+
}
|
|
41698
|
+
try {
|
|
41699
|
+
const provider = this.otelApi.trace.getTracerProvider();
|
|
41700
|
+
if (provider && typeof provider.forceFlush === 'function') {
|
|
41701
|
+
await provider.forceFlush();
|
|
41702
|
+
}
|
|
41703
|
+
}
|
|
41704
|
+
catch {
|
|
41705
|
+
// Ignore flush errors
|
|
41706
|
+
}
|
|
41707
|
+
}
|
|
41708
|
+
async shutdown() {
|
|
41709
|
+
if (this.shutdownInvoked) {
|
|
41710
|
+
return;
|
|
41711
|
+
}
|
|
41712
|
+
this.shutdownInvoked = true;
|
|
41713
|
+
const cleanupTasks = [];
|
|
41714
|
+
const strategy = this.authStrategy;
|
|
41715
|
+
if (strategy) {
|
|
41716
|
+
this.authStrategy = null;
|
|
41717
|
+
cleanupTasks.push(strategy.cleanup().catch(() => {
|
|
41718
|
+
// Ignore auth cleanup failures
|
|
41719
|
+
}));
|
|
41720
|
+
}
|
|
41721
|
+
if (this.lifecycle?.shutdown) {
|
|
41722
|
+
try {
|
|
41723
|
+
await this.lifecycle.shutdown();
|
|
41724
|
+
this.lifecycle = null;
|
|
41725
|
+
await Promise.all(cleanupTasks);
|
|
41726
|
+
return;
|
|
41727
|
+
}
|
|
41728
|
+
catch {
|
|
41729
|
+
// fall through to global shutdown fallback
|
|
41730
|
+
this.lifecycle = null;
|
|
41731
|
+
}
|
|
41732
|
+
}
|
|
41733
|
+
try {
|
|
41734
|
+
const provider = this.otelApi.trace.getTracerProvider();
|
|
41735
|
+
if (provider && typeof provider.shutdown === 'function') {
|
|
41736
|
+
await provider.shutdown();
|
|
41737
|
+
}
|
|
41738
|
+
}
|
|
41739
|
+
catch {
|
|
41740
|
+
// Ignore shutdown errors
|
|
41741
|
+
}
|
|
41742
|
+
finally {
|
|
41743
|
+
if (cleanupTasks.length > 0) {
|
|
41744
|
+
await Promise.all(cleanupTasks);
|
|
41745
|
+
}
|
|
41746
|
+
}
|
|
41747
|
+
}
|
|
41748
|
+
applyEnvelopeTraceId(span, envelopeTraceId) {
|
|
41749
|
+
try {
|
|
41750
|
+
const targetTraceId = this.convertEnvTraceIdToOtel(envelopeTraceId);
|
|
41751
|
+
const internalSpan = span;
|
|
41752
|
+
if (internalSpan?._spanContext) {
|
|
41753
|
+
internalSpan._spanContext.traceId = targetTraceId;
|
|
41754
|
+
}
|
|
41755
|
+
}
|
|
41756
|
+
catch {
|
|
41757
|
+
// Ignore trace-id coercion errors
|
|
41758
|
+
}
|
|
41759
|
+
}
|
|
41760
|
+
convertEnvTraceIdToOtel(envTraceId) {
|
|
41761
|
+
const normalized = envTraceId.slice(0, 16).padEnd(16, '0');
|
|
41762
|
+
let hex = '';
|
|
41763
|
+
for (let i = 0; i < 16; i += 1) {
|
|
41764
|
+
const code = normalized.charCodeAt(i);
|
|
41765
|
+
const byte = Number.isNaN(code) ? 0 : code & 0xff;
|
|
41766
|
+
hex += byte.toString(16).padStart(2, '0');
|
|
41767
|
+
}
|
|
41768
|
+
return hex;
|
|
41769
|
+
}
|
|
41770
|
+
}
|
|
41771
|
+
function normalizeOpenTelemetryTraceEmitterOptions(input) {
|
|
41772
|
+
const source = (input ?? {});
|
|
41773
|
+
const serviceName = extractNonEmptyString$1(pickFirst$1(source, ['serviceName', 'service_name'])) ?? 'naylence-service';
|
|
41774
|
+
const tracer = pickFirst$1(source, ['tracer']);
|
|
41775
|
+
const otelApi = pickFirst$1(source, [
|
|
41776
|
+
'otelApi',
|
|
41777
|
+
'otel_api',
|
|
41778
|
+
]);
|
|
41779
|
+
if (!otelApi) {
|
|
41780
|
+
throw new Error('OpenTelemetryTraceEmitter requires OpenTelemetry API bindings. Provide otelApi via options.');
|
|
41781
|
+
}
|
|
41782
|
+
const lifecycle = pickFirst$1(source, [
|
|
41783
|
+
'lifecycle',
|
|
41784
|
+
'lifeCycle',
|
|
41785
|
+
'life_cycle',
|
|
41786
|
+
]) ?? null;
|
|
41787
|
+
const authStrategy = pickFirst$1(source, [
|
|
41788
|
+
'authStrategy',
|
|
41789
|
+
'auth_strategy',
|
|
41790
|
+
]) ?? null;
|
|
41791
|
+
return {
|
|
41792
|
+
serviceName,
|
|
41793
|
+
tracer,
|
|
41794
|
+
otelApi,
|
|
41795
|
+
lifecycle,
|
|
41796
|
+
authStrategy,
|
|
41797
|
+
};
|
|
41798
|
+
}
|
|
41799
|
+
function pickFirst$1(source, keys) {
|
|
41800
|
+
for (const key of keys) {
|
|
41801
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
41802
|
+
const value = source[key];
|
|
41803
|
+
if (value !== undefined) {
|
|
41804
|
+
return value;
|
|
41805
|
+
}
|
|
41806
|
+
}
|
|
41807
|
+
}
|
|
41808
|
+
return undefined;
|
|
41809
|
+
}
|
|
41810
|
+
function extractNonEmptyString$1(value) {
|
|
41811
|
+
if (typeof value === 'string') {
|
|
41812
|
+
const trimmed = value.trim();
|
|
41813
|
+
if (trimmed.length > 0) {
|
|
41814
|
+
return trimmed;
|
|
41815
|
+
}
|
|
41816
|
+
}
|
|
41817
|
+
return undefined;
|
|
41818
|
+
}
|
|
41819
|
+
function normalizeAttributeValue(value) {
|
|
41820
|
+
if (Array.isArray(value)) {
|
|
41821
|
+
return value.map((item) => String(normalizePrimitiveAttribute(item, true)));
|
|
41822
|
+
}
|
|
41823
|
+
return normalizePrimitiveAttribute(value, false);
|
|
41824
|
+
}
|
|
41825
|
+
function normalizePrimitiveAttribute(value, forceString) {
|
|
41826
|
+
if (!forceString) {
|
|
41827
|
+
if (typeof value === 'string' ||
|
|
41828
|
+
typeof value === 'number' ||
|
|
41829
|
+
typeof value === 'boolean') {
|
|
41830
|
+
return value;
|
|
41831
|
+
}
|
|
41832
|
+
if (value instanceof Date) {
|
|
41833
|
+
return value.toISOString();
|
|
41834
|
+
}
|
|
41835
|
+
}
|
|
41836
|
+
if (value instanceof Date) {
|
|
41837
|
+
return value.toISOString();
|
|
41838
|
+
}
|
|
41839
|
+
if (typeof value === 'boolean') {
|
|
41840
|
+
return value;
|
|
41841
|
+
}
|
|
41842
|
+
if (!forceString && typeof value === 'number') {
|
|
41843
|
+
return value;
|
|
41844
|
+
}
|
|
41845
|
+
return String(value);
|
|
41846
|
+
}
|
|
41847
|
+
function normalizeAttributes(source) {
|
|
41848
|
+
if (!source) {
|
|
41849
|
+
return undefined;
|
|
41850
|
+
}
|
|
41851
|
+
const entries = [];
|
|
41852
|
+
for (const [key, raw] of Object.entries(source)) {
|
|
41853
|
+
entries.push([key, normalizeAttributeValue(raw)]);
|
|
41854
|
+
}
|
|
41855
|
+
return entries.length > 0 ? Object.fromEntries(entries) : undefined;
|
|
41856
|
+
}
|
|
41857
|
+
|
|
41858
|
+
var openTelemetryTraceEmitter = /*#__PURE__*/Object.freeze({
|
|
41859
|
+
__proto__: null,
|
|
41860
|
+
OpenTelemetryTraceEmitter: OpenTelemetryTraceEmitter
|
|
41861
|
+
});
|
|
41862
|
+
|
|
41863
|
+
const logger = getLogger('naylence.fame.telemetry.otel_setup');
|
|
41864
|
+
const stringFrom = (...codes) => String.fromCharCode(...codes);
|
|
41865
|
+
const OTEL_PREFIX = `${stringFrom(64, 111, 112, 101, 110, 116, 101, 108, 101, 109, 101, 116, 114, 121)}${stringFrom(47)}`;
|
|
41866
|
+
const OTEL_API_SPEC = `${OTEL_PREFIX}${stringFrom(97, 112, 105)}`;
|
|
41867
|
+
const OTEL_RESOURCES_SPEC = `${OTEL_PREFIX}${stringFrom(114, 101, 115, 111, 117, 114, 99, 101, 115)}`;
|
|
41868
|
+
const OTEL_TRACE_NODE_SPEC = `${OTEL_PREFIX}${stringFrom(115, 100, 107, 45, 116, 114, 97, 99, 101, 45, 110, 111, 100, 101)}`;
|
|
41869
|
+
const OTEL_TRACE_BASE_SPEC = `${OTEL_PREFIX}${stringFrom(115, 100, 107, 45, 116, 114, 97, 99, 101, 45, 98, 97, 115, 101)}`;
|
|
41870
|
+
const OTEL_EXPORTER_HTTP_SPEC = `${OTEL_PREFIX}${stringFrom(101, 120, 112, 111, 114, 116, 101, 114, 45, 116, 114, 97, 99, 101, 45, 111, 116, 108, 112, 45, 104, 116, 116, 112)}`;
|
|
41871
|
+
let registeredOtel = null;
|
|
41872
|
+
async function setupOtel(options) {
|
|
41873
|
+
const normalized = normalizeSetupOtelOptions(options);
|
|
41874
|
+
try {
|
|
41875
|
+
if (registeredOtel) {
|
|
41876
|
+
logger.debug('open_telemetry_reusing_provider', {
|
|
41877
|
+
service_name: normalized.serviceName,
|
|
41878
|
+
});
|
|
41879
|
+
return registeredOtel.control;
|
|
41880
|
+
}
|
|
41881
|
+
const [apiModule, resourcesModule, nodeModule, traceBaseModule] = await Promise.all([
|
|
41882
|
+
import(OTEL_API_SPEC),
|
|
41883
|
+
import(OTEL_RESOURCES_SPEC),
|
|
41884
|
+
import(OTEL_TRACE_NODE_SPEC),
|
|
41885
|
+
import(OTEL_TRACE_BASE_SPEC),
|
|
41886
|
+
]);
|
|
41887
|
+
const { trace } = apiModule;
|
|
41888
|
+
const { defaultResource, resourceFromAttributes } = resourcesModule;
|
|
41889
|
+
const { NodeTracerProvider } = nodeModule;
|
|
41890
|
+
const { BatchSpanProcessor, ConsoleSpanExporter, ParentBasedSampler, AlwaysOnSampler, AlwaysOffSampler, TraceIdRatioBasedSampler, } = traceBaseModule;
|
|
41891
|
+
const currentProvider = trace.getTracerProvider();
|
|
41892
|
+
if (currentProvider && currentProvider instanceof NodeTracerProvider) {
|
|
41893
|
+
return null;
|
|
41894
|
+
}
|
|
41895
|
+
if (currentProvider &&
|
|
41896
|
+
currentProvider.constructor?.name === 'NodeTracerProvider') {
|
|
41897
|
+
logger.debug('open_telemetry_existing_node_provider', {
|
|
41898
|
+
service_name: normalized.serviceName,
|
|
41899
|
+
});
|
|
41900
|
+
return null;
|
|
41901
|
+
}
|
|
41902
|
+
logger.debug('open_telemetry_initializing', {
|
|
41903
|
+
service_name: normalized.serviceName,
|
|
41904
|
+
endpoint: normalized.endpoint ?? null,
|
|
41905
|
+
environment: normalized.environment ?? null,
|
|
41906
|
+
sampler: normalized.sampler ?? null,
|
|
41907
|
+
headers_present: Boolean(normalized.headers && Object.keys(normalized.headers).length),
|
|
41908
|
+
});
|
|
41909
|
+
const sampler = resolveSampler(normalized.sampler, {
|
|
41910
|
+
ParentBasedSampler,
|
|
41911
|
+
AlwaysOnSampler,
|
|
41912
|
+
AlwaysOffSampler,
|
|
41913
|
+
TraceIdRatioBasedSampler,
|
|
41914
|
+
});
|
|
41915
|
+
const baseResource = defaultResource();
|
|
41916
|
+
const mergedResource = resourceFromAttributes({
|
|
41917
|
+
'service.name': normalized.serviceName,
|
|
41918
|
+
'service.instance.id': generateInstanceId(),
|
|
41919
|
+
'deployment.environment': normalized.environment ?? 'dev',
|
|
41920
|
+
});
|
|
41921
|
+
const resource = baseResource.merge(mergedResource);
|
|
41922
|
+
const exporter = await resolveExporter(normalized.endpoint ?? undefined, normalized.headers, ConsoleSpanExporter);
|
|
41923
|
+
const spanProcessor = new BatchSpanProcessor(exporter);
|
|
41924
|
+
const provider = new NodeTracerProvider({
|
|
41925
|
+
resource,
|
|
41926
|
+
sampler,
|
|
41927
|
+
spanProcessors: [spanProcessor],
|
|
41928
|
+
});
|
|
41929
|
+
provider.register();
|
|
41930
|
+
logger.debug('open_telemetry_initialized', {
|
|
41931
|
+
service_name: normalized.serviceName,
|
|
41932
|
+
exporter: exporter.constructor?.name ?? 'unknown_exporter',
|
|
41933
|
+
});
|
|
41934
|
+
const control = {
|
|
41935
|
+
forceFlush: async () => {
|
|
41936
|
+
try {
|
|
41937
|
+
await provider.forceFlush();
|
|
41938
|
+
}
|
|
41939
|
+
catch (flushError) {
|
|
41940
|
+
logger.warning('open_telemetry_force_flush_failed', {
|
|
41941
|
+
error: flushError instanceof Error
|
|
41942
|
+
? flushError.message
|
|
41943
|
+
: String(flushError),
|
|
41944
|
+
});
|
|
41945
|
+
}
|
|
41946
|
+
},
|
|
41947
|
+
shutdown: async () => {
|
|
41948
|
+
try {
|
|
41949
|
+
await provider.shutdown();
|
|
41950
|
+
}
|
|
41951
|
+
catch (shutdownError) {
|
|
41952
|
+
logger.warning('open_telemetry_shutdown_failed', {
|
|
41953
|
+
error: shutdownError instanceof Error
|
|
41954
|
+
? shutdownError.message
|
|
41955
|
+
: String(shutdownError),
|
|
41956
|
+
});
|
|
41957
|
+
}
|
|
41958
|
+
finally {
|
|
41959
|
+
registeredOtel = null;
|
|
41960
|
+
}
|
|
41961
|
+
},
|
|
41962
|
+
};
|
|
41963
|
+
registeredOtel = {
|
|
41964
|
+
provider,
|
|
41965
|
+
control,
|
|
41966
|
+
};
|
|
41967
|
+
return control;
|
|
41968
|
+
}
|
|
41969
|
+
catch (error) {
|
|
41970
|
+
logger.error('open_telemetry_not_available', {
|
|
41971
|
+
error: error instanceof Error ? error.message : String(error),
|
|
41972
|
+
stack: error instanceof Error && error.stack ? error.stack : undefined,
|
|
41973
|
+
});
|
|
41974
|
+
return null;
|
|
41975
|
+
}
|
|
41976
|
+
}
|
|
41977
|
+
function normalizeSetupOtelOptions(options) {
|
|
41978
|
+
const source = (options ?? {});
|
|
41979
|
+
const serviceName = extractNonEmptyString(pickFirst(source, ['serviceName', 'service_name'])) ??
|
|
41980
|
+
'naylence-service';
|
|
41981
|
+
const endpoint = extractNonEmptyString(pickFirst(source, ['endpoint', 'otlpEndpoint', 'otlp_endpoint'])) ?? null;
|
|
41982
|
+
const environment = extractNonEmptyString(pickFirst(source, [
|
|
41983
|
+
'environment',
|
|
41984
|
+
'deploymentEnvironment',
|
|
41985
|
+
'deployment_environment',
|
|
41986
|
+
])) ?? null;
|
|
41987
|
+
const sampler = extractNonEmptyString(pickFirst(source, ['sampler', 'samplingStrategy', 'sampling_strategy'])) ?? null;
|
|
41988
|
+
const headers = extractHeaders(pickFirst(source, ['headers', 'otlpHeaders', 'otlp_headers']));
|
|
41989
|
+
return {
|
|
41990
|
+
serviceName,
|
|
41991
|
+
endpoint,
|
|
41992
|
+
environment,
|
|
41993
|
+
sampler,
|
|
41994
|
+
headers: headers ?? undefined,
|
|
41995
|
+
};
|
|
41996
|
+
}
|
|
41997
|
+
function pickFirst(source, keys) {
|
|
41998
|
+
for (const key of keys) {
|
|
41999
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
42000
|
+
const value = source[key];
|
|
42001
|
+
if (value !== undefined) {
|
|
42002
|
+
return value;
|
|
42003
|
+
}
|
|
42004
|
+
}
|
|
42005
|
+
}
|
|
42006
|
+
return undefined;
|
|
42007
|
+
}
|
|
42008
|
+
function extractNonEmptyString(value) {
|
|
42009
|
+
if (typeof value === 'string') {
|
|
42010
|
+
const trimmed = value.trim();
|
|
42011
|
+
if (trimmed.length > 0) {
|
|
42012
|
+
return trimmed;
|
|
42013
|
+
}
|
|
42014
|
+
}
|
|
42015
|
+
return undefined;
|
|
42016
|
+
}
|
|
42017
|
+
function extractHeaders(value) {
|
|
42018
|
+
if (!value || typeof value !== 'object') {
|
|
42019
|
+
return null;
|
|
42020
|
+
}
|
|
42021
|
+
const headers = {};
|
|
42022
|
+
for (const [key, raw] of Object.entries(value)) {
|
|
42023
|
+
if (typeof raw === 'string') {
|
|
42024
|
+
headers[key] = raw;
|
|
42025
|
+
}
|
|
42026
|
+
}
|
|
42027
|
+
return Object.keys(headers).length > 0 ? headers : null;
|
|
42028
|
+
}
|
|
42029
|
+
function generateInstanceId() {
|
|
42030
|
+
try {
|
|
42031
|
+
if (typeof crypto !== 'undefined' &&
|
|
42032
|
+
typeof crypto.randomUUID === 'function') {
|
|
42033
|
+
return crypto.randomUUID().replace(/-/g, '');
|
|
42034
|
+
}
|
|
42035
|
+
}
|
|
42036
|
+
catch {
|
|
42037
|
+
// Ignore crypto availability errors
|
|
42038
|
+
}
|
|
42039
|
+
const random = Math.random().toString(16).slice(2);
|
|
42040
|
+
return random.padEnd(32, '0').slice(0, 32);
|
|
42041
|
+
}
|
|
42042
|
+
function resolveSampler(samplerSetting, samplers) {
|
|
42043
|
+
const normalized = (samplerSetting ?? 'parentbased_always_on').toLowerCase();
|
|
42044
|
+
let base;
|
|
42045
|
+
if (normalized === 'always_off') {
|
|
42046
|
+
base = new samplers.AlwaysOffSampler();
|
|
42047
|
+
}
|
|
42048
|
+
else if (normalized === 'always_on' ||
|
|
42049
|
+
normalized === 'parentbased_always_on') {
|
|
42050
|
+
base = new samplers.AlwaysOnSampler();
|
|
42051
|
+
}
|
|
42052
|
+
else if (normalized.startsWith('ratio:')) {
|
|
42053
|
+
const ratioValue = Number.parseFloat(normalized.slice('ratio:'.length));
|
|
42054
|
+
const ratio = Number.isFinite(ratioValue)
|
|
42055
|
+
? Math.min(Math.max(ratioValue, 0), 1)
|
|
42056
|
+
: 1;
|
|
42057
|
+
base = new samplers.TraceIdRatioBasedSampler(ratio);
|
|
42058
|
+
}
|
|
42059
|
+
else {
|
|
42060
|
+
base = new samplers.AlwaysOnSampler();
|
|
42061
|
+
}
|
|
42062
|
+
return new samplers.ParentBasedSampler({ root: base });
|
|
42063
|
+
}
|
|
42064
|
+
async function resolveExporter(endpoint, headers, ConsoleSpanExporter) {
|
|
42065
|
+
if (endpoint) {
|
|
42066
|
+
try {
|
|
42067
|
+
const exporterModule = await import(OTEL_EXPORTER_HTTP_SPEC);
|
|
42068
|
+
if ('OTLPTraceExporter' in exporterModule) {
|
|
42069
|
+
const { OTLPTraceExporter } = exporterModule;
|
|
42070
|
+
const exporterOptions = {
|
|
42071
|
+
url: endpoint,
|
|
42072
|
+
};
|
|
42073
|
+
if (headers && Object.keys(headers).length > 0) {
|
|
42074
|
+
exporterOptions.headers = headers;
|
|
42075
|
+
}
|
|
42076
|
+
logger.debug('open_telemetry_using_otlp_http_exporter', {
|
|
42077
|
+
endpoint,
|
|
42078
|
+
headers_present: Boolean(headers && Object.keys(headers).length),
|
|
42079
|
+
});
|
|
42080
|
+
return new OTLPTraceExporter(exporterOptions);
|
|
42081
|
+
}
|
|
42082
|
+
}
|
|
42083
|
+
catch (error) {
|
|
42084
|
+
logger.error('open_telemetry_exporter_not_available', {
|
|
42085
|
+
error: error instanceof Error ? error.message : String(error),
|
|
42086
|
+
});
|
|
42087
|
+
}
|
|
42088
|
+
}
|
|
42089
|
+
logger.warning('open_telemetry_falling_back_to_console_exporter');
|
|
42090
|
+
return new ConsoleSpanExporter();
|
|
42091
|
+
}
|
|
42092
|
+
|
|
42093
|
+
var otelSetup = /*#__PURE__*/Object.freeze({
|
|
42094
|
+
__proto__: null,
|
|
42095
|
+
setupOtel: setupOtel
|
|
42096
|
+
});
|
|
42097
|
+
|
|
41969
42098
|
class WebSocketTransportProvisioner {
|
|
41970
42099
|
constructor(options) {
|
|
41971
42100
|
this.url = options.url;
|