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