@naylence/runtime 0.4.5 → 0.4.7

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.
Files changed (42) hide show
  1. package/dist/browser/index.cjs +179 -127
  2. package/dist/browser/index.mjs +177 -129
  3. package/dist/cjs/naylence/fame/delivery/delivery-profile-factory.js +5 -9
  4. package/dist/cjs/naylence/fame/index.js +1 -0
  5. package/dist/cjs/naylence/fame/node/admission/admission-profile-factory.js +15 -19
  6. package/dist/cjs/naylence/fame/node/node-identity-policy-profile-factory.js +6 -10
  7. package/dist/cjs/naylence/fame/profile/index.js +8 -0
  8. package/dist/cjs/naylence/fame/profile/profile-registry.js +57 -0
  9. package/dist/cjs/naylence/fame/security/auth/authorization-profile-factory.js +64 -30
  10. package/dist/cjs/naylence/fame/security/default-security-manager-factory.js +4 -3
  11. package/dist/cjs/naylence/fame/security/node-security-profile-factory.js +9 -13
  12. package/dist/cjs/naylence/fame/sentinel/load-balancing/load-balancing-profile-factory.js +10 -13
  13. package/dist/cjs/naylence/fame/sentinel/routing-profile-factory.js +7 -8
  14. package/dist/cjs/naylence/fame/storage/storage-profile-factory.js +8 -12
  15. package/dist/cjs/naylence/fame/telemetry/trace-emitter-profile-factory.js +5 -9
  16. package/dist/cjs/runtime-isomorphic.js +1 -0
  17. package/dist/cjs/version.js +2 -2
  18. package/dist/esm/naylence/fame/delivery/delivery-profile-factory.js +5 -9
  19. package/dist/esm/naylence/fame/index.js +1 -0
  20. package/dist/esm/naylence/fame/node/admission/admission-profile-factory.js +15 -19
  21. package/dist/esm/naylence/fame/node/node-identity-policy-profile-factory.js +6 -10
  22. package/dist/esm/naylence/fame/profile/index.js +1 -0
  23. package/dist/esm/naylence/fame/profile/profile-registry.js +51 -0
  24. package/dist/esm/naylence/fame/security/auth/authorization-profile-factory.js +65 -31
  25. package/dist/esm/naylence/fame/security/default-security-manager-factory.js +4 -3
  26. package/dist/esm/naylence/fame/security/node-security-profile-factory.js +9 -13
  27. package/dist/esm/naylence/fame/sentinel/load-balancing/load-balancing-profile-factory.js +10 -13
  28. package/dist/esm/naylence/fame/sentinel/routing-profile-factory.js +7 -8
  29. package/dist/esm/naylence/fame/storage/storage-profile-factory.js +8 -12
  30. package/dist/esm/naylence/fame/telemetry/trace-emitter-profile-factory.js +5 -9
  31. package/dist/esm/runtime-isomorphic.js +1 -0
  32. package/dist/esm/version.js +2 -2
  33. package/dist/node/index.cjs +179 -127
  34. package/dist/node/index.mjs +177 -129
  35. package/dist/node/node.cjs +182 -128
  36. package/dist/node/node.mjs +180 -130
  37. package/dist/types/naylence/fame/index.d.ts +1 -0
  38. package/dist/types/naylence/fame/profile/index.d.ts +2 -0
  39. package/dist/types/naylence/fame/profile/profile-registry.d.ts +9 -0
  40. package/dist/types/runtime-isomorphic.d.ts +1 -0
  41. package/dist/types/version.d.ts +1 -1
  42. package/package.json +1 -1
@@ -525,12 +525,12 @@ async function ensureRuntimeFactoriesRegistered(registry = factory.Registry) {
525
525
  }
526
526
 
527
527
  // This file is auto-generated during build - do not edit manually
528
- // Generated from package.json version: 0.4.5
528
+ // Generated from package.json version: 0.4.7
529
529
  /**
530
530
  * The package version, injected at build time.
531
531
  * @internal
532
532
  */
533
- const VERSION = '0.4.5';
533
+ const VERSION = '0.4.7';
534
534
 
535
535
  let initialized = false;
536
536
  const runtimePlugin = {
@@ -3561,6 +3561,58 @@ class InMemoryFanoutBroker extends TaskSpawner {
3561
3561
  }
3562
3562
  }
3563
3563
 
3564
+ const registry = new Map();
3565
+ function normalizeKey$1(value, label) {
3566
+ if (typeof value !== 'string') {
3567
+ throw new Error(`${label} must be a non-empty string`);
3568
+ }
3569
+ const trimmed = value.trim();
3570
+ if (!trimmed) {
3571
+ throw new Error(`${label} must be a non-empty string`);
3572
+ }
3573
+ return trimmed;
3574
+ }
3575
+ function cloneConfig(value) {
3576
+ return JSON.parse(JSON.stringify(value));
3577
+ }
3578
+ function registerProfile(baseType, name, config, options) {
3579
+ const normalizedBase = normalizeKey$1(baseType, 'baseType');
3580
+ const normalizedName = normalizeKey$1(name, 'profile name');
3581
+ if (!config || typeof config !== 'object' || Array.isArray(config)) {
3582
+ throw new Error(`Profile '${normalizedName}' config must be an object`);
3583
+ }
3584
+ const profiles = registry.get(normalizedBase) ?? new Map();
3585
+ if (profiles.has(normalizedName) && options?.allowOverride !== true) {
3586
+ const sourceLabel = options?.source ? ` (${options.source})` : '';
3587
+ throw new Error(`Profile '${normalizedName}' already registered for ${normalizedBase}${sourceLabel}`);
3588
+ }
3589
+ profiles.set(normalizedName, config);
3590
+ registry.set(normalizedBase, profiles);
3591
+ }
3592
+ function getProfile(baseType, name) {
3593
+ const normalizedBase = normalizeKey$1(baseType, 'baseType');
3594
+ const normalizedName = normalizeKey$1(name, 'profile name');
3595
+ const profiles = registry.get(normalizedBase);
3596
+ if (!profiles) {
3597
+ return null;
3598
+ }
3599
+ const profile = profiles.get(normalizedName);
3600
+ return profile ? cloneConfig(profile) : null;
3601
+ }
3602
+ function listProfiles(baseType) {
3603
+ const normalizedBase = normalizeKey$1(baseType, 'baseType');
3604
+ const profiles = registry.get(normalizedBase);
3605
+ return profiles ? Array.from(profiles.keys()) : [];
3606
+ }
3607
+ function clearProfiles(baseType) {
3608
+ if (!baseType) {
3609
+ registry.clear();
3610
+ return;
3611
+ }
3612
+ const normalizedBase = normalizeKey$1(baseType, 'baseType');
3613
+ registry.delete(normalizedBase);
3614
+ }
3615
+
3564
3616
  class InMemoryKeyValueStore {
3565
3617
  constructor() {
3566
3618
  this.store = new Map();
@@ -4202,15 +4254,8 @@ const INDEXEDDB_PROFILE_CONFIG = {
4202
4254
  ({
4203
4255
  dbDirectory: factory.Expressions.env(ENV_VAR_STORAGE_DB_DIRECTORY, './data/sqlite'),
4204
4256
  masterKey: factory.Expressions.env(ENV_VAR_STORAGE_MASTER_KEY)});
4205
- // Base profile map with browser-safe options
4206
- const BASE_PROFILE_MAP = {
4207
- [PROFILE_NAME_MEMORY]: MEMORY_PROFILE_CONFIG,
4208
- [PROFILE_NAME_INDEXEDDB]: INDEXEDDB_PROFILE_CONFIG,
4209
- };
4210
- // Extended profile map - can be augmented by Node.js environment
4211
- const PROFILE_MAP$7 = {
4212
- ...BASE_PROFILE_MAP,
4213
- };
4257
+ registerProfile(STORAGE_PROVIDER_FACTORY_BASE_TYPE, PROFILE_NAME_MEMORY, MEMORY_PROFILE_CONFIG, { source: 'storage-profile-factory' });
4258
+ registerProfile(STORAGE_PROVIDER_FACTORY_BASE_TYPE, PROFILE_NAME_INDEXEDDB, INDEXEDDB_PROFILE_CONFIG, { source: 'storage-profile-factory' });
4214
4259
  class StorageProfileFactory extends StorageProviderFactory {
4215
4260
  constructor() {
4216
4261
  super(...arguments);
@@ -4223,9 +4268,9 @@ class StorageProfileFactory extends StorageProviderFactory {
4223
4268
  type: 'StorageProfile',
4224
4269
  });
4225
4270
  const profileName = (parsed.profile ?? PROFILE_NAME_MEMORY).toLowerCase();
4226
- const profileConfig = PROFILE_MAP$7[profileName];
4271
+ const profileConfig = getProfile(STORAGE_PROVIDER_FACTORY_BASE_TYPE, profileName);
4227
4272
  if (!profileConfig) {
4228
- throw new Error(`Unknown storage profile '${profileName}'. Supported profiles: ${Object.keys(PROFILE_MAP$7).join(', ')}`);
4273
+ throw new Error(`Unknown storage profile '${profileName}'. Supported profiles: ${listProfiles(STORAGE_PROVIDER_FACTORY_BASE_TYPE).join(', ')}`);
4229
4274
  }
4230
4275
  const createOptions = {
4231
4276
  ...options,
@@ -16193,11 +16238,9 @@ const DEFAULT_PROFILE$1 = {
16193
16238
  const TOKEN_SUBJECT_PROFILE = {
16194
16239
  type: 'TokenSubjectNodeIdentityPolicy',
16195
16240
  };
16196
- const PROFILE_MAP$6 = {
16197
- [PROFILE_NAME_DEFAULT$1]: DEFAULT_PROFILE$1,
16198
- [PROFILE_NAME_TOKEN_SUBJECT]: TOKEN_SUBJECT_PROFILE,
16199
- [PROFILE_NAME_TOKEN_SUBJECT_ALIAS]: TOKEN_SUBJECT_PROFILE,
16200
- };
16241
+ registerProfile(NODE_IDENTITY_POLICY_FACTORY_BASE_TYPE, PROFILE_NAME_DEFAULT$1, DEFAULT_PROFILE$1, { source: 'node-identity-policy-profile-factory' });
16242
+ registerProfile(NODE_IDENTITY_POLICY_FACTORY_BASE_TYPE, PROFILE_NAME_TOKEN_SUBJECT, TOKEN_SUBJECT_PROFILE, { source: 'node-identity-policy-profile-factory' });
16243
+ registerProfile(NODE_IDENTITY_POLICY_FACTORY_BASE_TYPE, PROFILE_NAME_TOKEN_SUBJECT_ALIAS, TOKEN_SUBJECT_PROFILE, { source: 'node-identity-policy-profile-factory' });
16201
16244
  const FACTORY_META$19 = {
16202
16245
  base: NODE_IDENTITY_POLICY_FACTORY_BASE_TYPE,
16203
16246
  key: 'NodeIdentityPolicyProfile',
@@ -16234,14 +16277,11 @@ function normalizeConfig$x(config) {
16234
16277
  return { profile: normalizedProfile };
16235
16278
  }
16236
16279
  function resolveProfileConfig$5(profileName) {
16237
- const profile = PROFILE_MAP$6[profileName];
16280
+ const profile = getProfile(NODE_IDENTITY_POLICY_FACTORY_BASE_TYPE, profileName);
16238
16281
  if (!profile) {
16239
16282
  throw new Error(`Unknown node identity policy profile: ${profileName}`);
16240
16283
  }
16241
- return deepClone$5(profile);
16242
- }
16243
- function deepClone$5(value) {
16244
- return JSON.parse(JSON.stringify(value));
16284
+ return profile;
16245
16285
  }
16246
16286
 
16247
16287
  var nodeIdentityPolicyProfileFactory = /*#__PURE__*/Object.freeze({
@@ -21941,14 +21981,13 @@ const ENV_VAR_JWT_REVERSE_AUTH_AUDIENCE$1 = 'FAME_JWT_REVERSE_AUTH_AUDIENCE';
21941
21981
  const ENV_VAR_HMAC_SECRET$1 = 'FAME_HMAC_SECRET';
21942
21982
  const DEFAULT_REVERSE_AUTH_ISSUER = 'reverse-auth.naylence.ai';
21943
21983
  const DEFAULT_REVERSE_AUTH_AUDIENCE = 'dev.naylence.ai';
21944
- const DEFAULT_VERIFIER_CONFIG = {
21945
- type: 'JWKSJWTTokenVerifier',
21946
- jwks_url: factory.Expressions.env(ENV_VAR_JWKS_URL$1),
21947
- issuer: factory.Expressions.env(ENV_VAR_JWT_TRUSTED_ISSUER$1),
21948
- };
21949
21984
  const DEFAULT_PROFILE = {
21950
21985
  type: 'DefaultAuthorizer',
21951
- verifier: DEFAULT_VERIFIER_CONFIG,
21986
+ verifier: {
21987
+ type: 'JWKSJWTTokenVerifier',
21988
+ jwks_url: factory.Expressions.env(ENV_VAR_JWKS_URL$1),
21989
+ issuer: factory.Expressions.env(ENV_VAR_JWT_TRUSTED_ISSUER$1),
21990
+ },
21952
21991
  };
21953
21992
  const OAUTH2_PROFILE = {
21954
21993
  type: 'OAuth2Authorizer',
@@ -21993,6 +22032,11 @@ const OAUTH2_CALLBACK_PROFILE = {
21993
22032
  const NOOP_PROFILE$2 = {
21994
22033
  type: 'NoopAuthorizer',
21995
22034
  };
22035
+ const DEFAULT_VERIFIER_CONFIG = {
22036
+ type: 'JWKSJWTTokenVerifier',
22037
+ jwks_url: factory.Expressions.env(ENV_VAR_JWKS_URL$1),
22038
+ issuer: factory.Expressions.env(ENV_VAR_JWT_TRUSTED_ISSUER$1),
22039
+ };
21996
22040
  const DEFAULT_POLICY_SOURCE = {
21997
22041
  type: 'LocalFileAuthorizationPolicySource',
21998
22042
  path: factory.Expressions.env(ENV_VAR_AUTH_POLICY_PATH, './auth-policy.yaml'),
@@ -22003,14 +22047,12 @@ const POLICY_LOCALFILE_PROFILE = {
22003
22047
  verifier: DEFAULT_VERIFIER_CONFIG,
22004
22048
  policySource: DEFAULT_POLICY_SOURCE,
22005
22049
  };
22006
- const PROFILE_MAP$5 = {
22007
- [PROFILE_NAME_DEFAULT]: DEFAULT_PROFILE,
22008
- [PROFILE_NAME_OAUTH2]: OAUTH2_PROFILE,
22009
- [PROFILE_NAME_OAUTH2_GATED]: OAUTH2_GATED_PROFILE,
22010
- [PROFILE_NAME_OAUTH2_CALLBACK]: OAUTH2_CALLBACK_PROFILE,
22011
- [PROFILE_NAME_POLICY_LOCALFILE]: POLICY_LOCALFILE_PROFILE,
22012
- [PROFILE_NAME_NOOP$2]: NOOP_PROFILE$2,
22013
- };
22050
+ registerProfile(AUTHORIZER_FACTORY_BASE_TYPE, PROFILE_NAME_DEFAULT, DEFAULT_PROFILE, { source: 'authorization-profile-factory' });
22051
+ registerProfile(AUTHORIZER_FACTORY_BASE_TYPE, PROFILE_NAME_OAUTH2, OAUTH2_PROFILE, { source: 'authorization-profile-factory' });
22052
+ registerProfile(AUTHORIZER_FACTORY_BASE_TYPE, PROFILE_NAME_OAUTH2_GATED, OAUTH2_GATED_PROFILE, { source: 'authorization-profile-factory' });
22053
+ registerProfile(AUTHORIZER_FACTORY_BASE_TYPE, PROFILE_NAME_OAUTH2_CALLBACK, OAUTH2_CALLBACK_PROFILE, { source: 'authorization-profile-factory' });
22054
+ registerProfile(AUTHORIZER_FACTORY_BASE_TYPE, PROFILE_NAME_POLICY_LOCALFILE, POLICY_LOCALFILE_PROFILE, { source: 'authorization-profile-factory' });
22055
+ registerProfile(AUTHORIZER_FACTORY_BASE_TYPE, PROFILE_NAME_NOOP$2, NOOP_PROFILE$2, { source: 'authorization-profile-factory' });
22014
22056
  const PROFILE_ALIASES$1 = {
22015
22057
  jwt: PROFILE_NAME_DEFAULT,
22016
22058
  jwks: PROFILE_NAME_DEFAULT,
@@ -22044,13 +22086,55 @@ class AuthorizationProfileFactory extends AuthorizerFactory {
22044
22086
  logger$K.debug('enabling_authorization_profile', {
22045
22087
  profile: normalized.profile,
22046
22088
  });
22047
- const authorizer = await AuthorizerFactory.createAuthorizer(profileConfig, { factoryArgs });
22089
+ // Extract CreateResourceOptions from factoryArgs - it's typically the last object with env/config/variables
22090
+ const createOptions = extractCreateResourceOptions(factoryArgs);
22091
+ // Only evaluate expressions if we have env/config/variables available
22092
+ let evaluatedConfig = profileConfig;
22093
+ const hasContext = createOptions.env || createOptions.config || createOptions.variables;
22094
+ if (hasContext) {
22095
+ // Build validation context from createOptions to evaluate expressions
22096
+ const validationContext = {
22097
+ env: createOptions.env,
22098
+ config: createOptions.config,
22099
+ variables: createOptions.variables,
22100
+ allowUnknownProperties: true,
22101
+ };
22102
+ // Evaluate expressions in the profile config
22103
+ const validationResult = factory.configValidator.validate(profileConfig, validationContext);
22104
+ if (!validationResult.valid) {
22105
+ const errorMessages = validationResult.errors
22106
+ .map((error) => `${error.path || 'root'}: ${error.message}`)
22107
+ .join('; ');
22108
+ throw new Error(`Failed to evaluate authorization profile configuration: ${errorMessages}`);
22109
+ }
22110
+ evaluatedConfig = validationResult.config ?? profileConfig;
22111
+ }
22112
+ const authorizer = await AuthorizerFactory.createAuthorizer(evaluatedConfig, hasContext ? { validate: false } : { factoryArgs } // Pass factoryArgs if no validation was done
22113
+ );
22048
22114
  if (!authorizer) {
22049
22115
  throw new Error(`Failed to create authorizer for profile: ${normalized.profile}`);
22050
22116
  }
22051
22117
  return authorizer;
22052
22118
  }
22053
22119
  }
22120
+ /**
22121
+ * Extracts CreateResourceOptions from factoryArgs.
22122
+ * The factory system passes CreateResourceOptions as an object in factoryArgs.
22123
+ */
22124
+ function extractCreateResourceOptions(factoryArgs) {
22125
+ // Find the last object argument that looks like CreateResourceOptions
22126
+ for (let i = factoryArgs.length - 1; i >= 0; i--) {
22127
+ const arg = factoryArgs[i];
22128
+ if (arg && typeof arg === 'object' && !Array.isArray(arg)) {
22129
+ const candidate = arg;
22130
+ // Check if it has typical CreateResourceOptions properties
22131
+ if ('env' in candidate || 'config' in candidate || 'variables' in candidate || 'factoryArgs' in candidate) {
22132
+ return candidate;
22133
+ }
22134
+ }
22135
+ }
22136
+ return {};
22137
+ }
22054
22138
  function normalizeConfig$w(config) {
22055
22139
  if (!config) {
22056
22140
  return { profile: PROFILE_NAME_OAUTH2 };
@@ -22062,21 +22146,13 @@ function normalizeConfig$w(config) {
22062
22146
  return { profile: canonicalProfile };
22063
22147
  }
22064
22148
  function resolveProfileName$2(candidate) {
22065
- let direct = coerceProfileString$2(candidate.profile);
22066
- if (direct && factory.ExpressionEvaluator.isExpression(direct)) {
22067
- const evaluated = factory.ExpressionEvaluator.evaluate(direct);
22068
- direct = coerceProfileString$2(evaluated);
22069
- }
22149
+ const direct = coerceProfileString$2(candidate.profile);
22070
22150
  if (direct) {
22071
22151
  return direct;
22072
22152
  }
22073
22153
  const legacyKeys = ['profile_name', 'profileName'];
22074
22154
  for (const legacyKey of legacyKeys) {
22075
- let legacyValue = coerceProfileString$2(candidate[legacyKey]);
22076
- if (legacyValue && factory.ExpressionEvaluator.isExpression(legacyValue)) {
22077
- const evaluated = factory.ExpressionEvaluator.evaluate(legacyValue);
22078
- legacyValue = coerceProfileString$2(evaluated);
22079
- }
22155
+ const legacyValue = coerceProfileString$2(candidate[legacyKey]);
22080
22156
  if (legacyValue) {
22081
22157
  return legacyValue;
22082
22158
  }
@@ -22095,14 +22171,11 @@ function canonicalizeProfileName$1(value) {
22095
22171
  return PROFILE_ALIASES$1[normalized] ?? normalized;
22096
22172
  }
22097
22173
  function resolveProfileConfig$4(profileName) {
22098
- const profile = PROFILE_MAP$5[profileName];
22174
+ const profile = getProfile(AUTHORIZER_FACTORY_BASE_TYPE, profileName);
22099
22175
  if (!profile) {
22100
22176
  throw new Error(`Unknown authorization profile: ${profileName}`);
22101
22177
  }
22102
- return deepClone$4(profile);
22103
- }
22104
- function deepClone$4(value) {
22105
- return JSON.parse(JSON.stringify(value));
22178
+ return profile;
22106
22179
  }
22107
22180
 
22108
22181
  var authorizationProfileFactory = /*#__PURE__*/Object.freeze({
@@ -29906,14 +29979,12 @@ const OPEN_PROFILE$1 = {
29906
29979
  profile: factory.Expressions.env(ENV_VAR_AUTHORIZATION_PROFILE, 'noop'),
29907
29980
  },
29908
29981
  };
29909
- const PROFILE_MAP$4 = {
29910
- [PROFILE_NAME_OVERLAY]: OVERLAY_PROFILE,
29911
- [PROFILE_NAME_OVERLAY_CALLBACK]: OVERLAY_CALLBACK_PROFILE,
29912
- [PROFILE_NAME_STRICT_OVERLAY]: STRICT_OVERLAY_PROFILE,
29913
- [PROFILE_NAME_GATED]: GATED_PROFILE,
29914
- [PROFILE_NAME_GATED_CALLBACK]: GATED_CALLBACK_PROFILE,
29915
- [PROFILE_NAME_OPEN$1]: OPEN_PROFILE$1,
29916
- };
29982
+ registerProfile(SECURITY_MANAGER_FACTORY_BASE_TYPE, PROFILE_NAME_OVERLAY, OVERLAY_PROFILE, { source: 'node-security-profile-factory' });
29983
+ registerProfile(SECURITY_MANAGER_FACTORY_BASE_TYPE, PROFILE_NAME_OVERLAY_CALLBACK, OVERLAY_CALLBACK_PROFILE, { source: 'node-security-profile-factory' });
29984
+ registerProfile(SECURITY_MANAGER_FACTORY_BASE_TYPE, PROFILE_NAME_STRICT_OVERLAY, STRICT_OVERLAY_PROFILE, { source: 'node-security-profile-factory' });
29985
+ registerProfile(SECURITY_MANAGER_FACTORY_BASE_TYPE, PROFILE_NAME_GATED, GATED_PROFILE, { source: 'node-security-profile-factory' });
29986
+ registerProfile(SECURITY_MANAGER_FACTORY_BASE_TYPE, PROFILE_NAME_GATED_CALLBACK, GATED_CALLBACK_PROFILE, { source: 'node-security-profile-factory' });
29987
+ registerProfile(SECURITY_MANAGER_FACTORY_BASE_TYPE, PROFILE_NAME_OPEN$1, OPEN_PROFILE$1, { source: 'node-security-profile-factory' });
29917
29988
  const FACTORY_META$13 = {
29918
29989
  base: SECURITY_MANAGER_FACTORY_BASE_TYPE,
29919
29990
  key: 'SecurityProfile',
@@ -30020,14 +30091,11 @@ function normalizeProfile(config) {
30020
30091
  return value.toLowerCase();
30021
30092
  }
30022
30093
  function resolveProfileConfig$3(profileName) {
30023
- const template = PROFILE_MAP$4[profileName];
30094
+ const template = getProfile(SECURITY_MANAGER_FACTORY_BASE_TYPE, profileName);
30024
30095
  if (!template) {
30025
30096
  throw new Error(`Unknown security profile: ${profileName}`);
30026
30097
  }
30027
- return deepClone$3(template);
30028
- }
30029
- function deepClone$3(value) {
30030
- return JSON.parse(JSON.stringify(value));
30098
+ return template;
30031
30099
  }
30032
30100
 
30033
30101
  var nodeSecurityProfileFactory = /*#__PURE__*/Object.freeze({
@@ -33952,10 +34020,8 @@ const AT_LEAST_ONCE_PROFILE = {
33952
34020
  const AT_MOST_ONCE_PROFILE = {
33953
34021
  type: 'AtMostOnceDeliveryPolicy',
33954
34022
  };
33955
- const PROFILE_MAP$3 = {
33956
- [PROFILE_NAME_AT_LEAST_ONCE]: AT_LEAST_ONCE_PROFILE,
33957
- [PROFILE_NAME_AT_MOST_ONCE]: AT_MOST_ONCE_PROFILE,
33958
- };
34023
+ registerProfile(DELIVERY_POLICY_FACTORY_BASE_TYPE, PROFILE_NAME_AT_LEAST_ONCE, AT_LEAST_ONCE_PROFILE, { source: 'delivery-profile-factory' });
34024
+ registerProfile(DELIVERY_POLICY_FACTORY_BASE_TYPE, PROFILE_NAME_AT_MOST_ONCE, AT_MOST_ONCE_PROFILE, { source: 'delivery-profile-factory' });
33959
34025
  class DeliveryProfileFactory extends DeliveryPolicyFactory {
33960
34026
  constructor() {
33961
34027
  super(...arguments);
@@ -34004,14 +34070,11 @@ function coerceProfileString$1(value) {
34004
34070
  return trimmed.length > 0 ? trimmed : null;
34005
34071
  }
34006
34072
  function resolveProfileConfig$2(profileName) {
34007
- const profile = PROFILE_MAP$3[profileName];
34073
+ const profile = getProfile(DELIVERY_POLICY_FACTORY_BASE_TYPE, profileName);
34008
34074
  if (!profile) {
34009
34075
  throw new Error(`Unknown delivery profile: ${profileName}`);
34010
34076
  }
34011
- return deepClone$2(profile);
34012
- }
34013
- function deepClone$2(value) {
34014
- return JSON.parse(JSON.stringify(value));
34077
+ return profile;
34015
34078
  }
34016
34079
  const FACTORY_META$S = {
34017
34080
  base: DELIVERY_POLICY_FACTORY_BASE_TYPE,
@@ -34448,20 +34511,18 @@ const NOOP_PROFILE$1 = {
34448
34511
  auto_accept_logicals: true,
34449
34512
  autoAcceptLogicals: true,
34450
34513
  };
34451
- const PROFILE_MAP$2 = {
34452
- [PROFILE_NAME_WELCOME]: WELCOME_SERVICE_PROFILE,
34453
- [PROFILE_NAME_WELCOME_PKCE]: WELCOME_SERVICE_PKCE_PROFILE,
34454
- [PROFILE_NAME_WELCOME_PKCE_ALIAS]: WELCOME_SERVICE_PKCE_PROFILE,
34455
- [PROFILE_NAME_DIRECT]: DIRECT_PROFILE,
34456
- [PROFILE_NAME_DIRECT_PKCE]: DIRECT_PKCE_PROFILE,
34457
- [PROFILE_NAME_DIRECT_PKCE_ALIAS]: DIRECT_PKCE_PROFILE,
34458
- [PROFILE_NAME_DIRECT_HTTP]: DIRECT_HTTP_PROFILE,
34459
- [PROFILE_NAME_DIRECT_INPAGE]: DIRECT_INPAGE_PROFILE,
34460
- [PROFILE_NAME_DIRECT_INPAGE_ALIAS]: DIRECT_INPAGE_PROFILE,
34461
- [PROFILE_NAME_OPEN]: OPEN_PROFILE,
34462
- [PROFILE_NAME_NOOP$1]: NOOP_PROFILE$1,
34463
- [PROFILE_NAME_NONE]: NOOP_PROFILE$1,
34464
- };
34514
+ registerProfile(ADMISSION_CLIENT_FACTORY_BASE_TYPE, PROFILE_NAME_WELCOME, WELCOME_SERVICE_PROFILE, { source: 'admission-profile-factory' });
34515
+ registerProfile(ADMISSION_CLIENT_FACTORY_BASE_TYPE, PROFILE_NAME_WELCOME_PKCE, WELCOME_SERVICE_PKCE_PROFILE, { source: 'admission-profile-factory' });
34516
+ registerProfile(ADMISSION_CLIENT_FACTORY_BASE_TYPE, PROFILE_NAME_WELCOME_PKCE_ALIAS, WELCOME_SERVICE_PKCE_PROFILE, { source: 'admission-profile-factory' });
34517
+ registerProfile(ADMISSION_CLIENT_FACTORY_BASE_TYPE, PROFILE_NAME_DIRECT, DIRECT_PROFILE, { source: 'admission-profile-factory' });
34518
+ registerProfile(ADMISSION_CLIENT_FACTORY_BASE_TYPE, PROFILE_NAME_DIRECT_PKCE, DIRECT_PKCE_PROFILE, { source: 'admission-profile-factory' });
34519
+ registerProfile(ADMISSION_CLIENT_FACTORY_BASE_TYPE, PROFILE_NAME_DIRECT_PKCE_ALIAS, DIRECT_PKCE_PROFILE, { source: 'admission-profile-factory' });
34520
+ registerProfile(ADMISSION_CLIENT_FACTORY_BASE_TYPE, PROFILE_NAME_DIRECT_HTTP, DIRECT_HTTP_PROFILE, { source: 'admission-profile-factory' });
34521
+ registerProfile(ADMISSION_CLIENT_FACTORY_BASE_TYPE, PROFILE_NAME_DIRECT_INPAGE, DIRECT_INPAGE_PROFILE, { source: 'admission-profile-factory' });
34522
+ registerProfile(ADMISSION_CLIENT_FACTORY_BASE_TYPE, PROFILE_NAME_DIRECT_INPAGE_ALIAS, DIRECT_INPAGE_PROFILE, { source: 'admission-profile-factory' });
34523
+ registerProfile(ADMISSION_CLIENT_FACTORY_BASE_TYPE, PROFILE_NAME_OPEN, OPEN_PROFILE, { source: 'admission-profile-factory' });
34524
+ registerProfile(ADMISSION_CLIENT_FACTORY_BASE_TYPE, PROFILE_NAME_NOOP$1, NOOP_PROFILE$1, { source: 'admission-profile-factory' });
34525
+ registerProfile(ADMISSION_CLIENT_FACTORY_BASE_TYPE, PROFILE_NAME_NONE, NOOP_PROFILE$1, { source: 'admission-profile-factory' });
34465
34526
  const FACTORY_META$Q = {
34466
34527
  base: ADMISSION_CLIENT_FACTORY_BASE_TYPE,
34467
34528
  key: 'AdmissionProfile',
@@ -34498,14 +34559,11 @@ function normalizeConfig$p(config) {
34498
34559
  return { profile: normalizedProfile };
34499
34560
  }
34500
34561
  function resolveProfileConfig$1(profileName) {
34501
- const profile = PROFILE_MAP$2[profileName];
34562
+ const profile = getProfile(ADMISSION_CLIENT_FACTORY_BASE_TYPE, profileName);
34502
34563
  if (!profile) {
34503
34564
  throw new Error(`Unknown admission profile: ${profileName}`);
34504
34565
  }
34505
- return deepClone$1(profile);
34506
- }
34507
- function deepClone$1(value) {
34508
- return JSON.parse(JSON.stringify(value));
34566
+ return profile;
34509
34567
  }
34510
34568
 
34511
34569
  var admissionProfileFactory = /*#__PURE__*/Object.freeze({
@@ -37415,7 +37473,7 @@ class DefaultSecurityManagerFactory extends SecurityManagerFactory {
37415
37473
  }
37416
37474
  if (!authorizer) {
37417
37475
  authorizer =
37418
- await DefaultSecurityManagerFactory.createAuthorizerFromConfig(config, policy);
37476
+ await DefaultSecurityManagerFactory.createAuthorizerFromConfig(config, policy, createOptions);
37419
37477
  }
37420
37478
  if (authorizer &&
37421
37479
  eventListeners &&
@@ -37646,14 +37704,14 @@ class DefaultSecurityManagerFactory extends SecurityManagerFactory {
37646
37704
  }
37647
37705
  return null;
37648
37706
  }
37649
- static async createAuthorizerFromConfig(config, policy) {
37707
+ static async createAuthorizerFromConfig(config, policy, createOptions) {
37650
37708
  let authorizerConfig = config.authorizer ?? null;
37651
37709
  if (!authorizerConfig) {
37652
37710
  authorizerConfig = config.authorizer_config ?? null;
37653
37711
  }
37654
37712
  if (authorizerConfig &&
37655
37713
  DefaultSecurityManagerFactory.isConfigLike(authorizerConfig)) {
37656
- return ((await AuthorizerFactory.createAuthorizer(authorizerConfig)) ?? null);
37714
+ return ((await AuthorizerFactory.createAuthorizer(authorizerConfig, createOptions ?? undefined)) ?? null);
37657
37715
  }
37658
37716
  try {
37659
37717
  const requirements = policy.requirements?.();
@@ -37669,6 +37727,7 @@ class DefaultSecurityManagerFactory extends SecurityManagerFactory {
37669
37727
  }
37670
37728
  const tokenVerifier = new NoopTokenVerifier();
37671
37729
  return ((await AuthorizerFactory.createAuthorizer(null, {
37730
+ ...createOptions,
37672
37731
  factoryArgs: [tokenVerifier],
37673
37732
  })) ?? null);
37674
37733
  }
@@ -38830,6 +38889,11 @@ const STICKY_HRW_PROFILE = {
38830
38889
  const DEVELOPMENT_PROFILE$1 = {
38831
38890
  type: 'RoundRobinLoadBalancingStrategy',
38832
38891
  };
38892
+ registerProfile(LOAD_BALANCING_STRATEGY_FACTORY_BASE, PROFILE_NAME_RANDOM, RANDOM_PROFILE, { source: 'load-balancing-profile-factory' });
38893
+ registerProfile(LOAD_BALANCING_STRATEGY_FACTORY_BASE, PROFILE_NAME_ROUND_ROBIN, ROUND_ROBIN_PROFILE, { source: 'load-balancing-profile-factory' });
38894
+ registerProfile(LOAD_BALANCING_STRATEGY_FACTORY_BASE, PROFILE_NAME_HRW, HRW_PROFILE, { source: 'load-balancing-profile-factory' });
38895
+ registerProfile(LOAD_BALANCING_STRATEGY_FACTORY_BASE, PROFILE_NAME_STICKY_HRW, STICKY_HRW_PROFILE, { source: 'load-balancing-profile-factory' });
38896
+ registerProfile(LOAD_BALANCING_STRATEGY_FACTORY_BASE, PROFILE_NAME_DEVELOPMENT$1, DEVELOPMENT_PROFILE$1, { source: 'load-balancing-profile-factory' });
38833
38897
  const FACTORY_META$7 = {
38834
38898
  base: LOAD_BALANCING_STRATEGY_FACTORY_BASE,
38835
38899
  key: 'LoadBalancingProfile',
@@ -38884,20 +38948,11 @@ class LoadBalancingProfileFactory extends LoadBalancingStrategyFactory {
38884
38948
  return undefined;
38885
38949
  }
38886
38950
  resolveProfile(profile) {
38887
- switch (profile) {
38888
- case PROFILE_NAME_RANDOM:
38889
- return RANDOM_PROFILE;
38890
- case PROFILE_NAME_ROUND_ROBIN:
38891
- return ROUND_ROBIN_PROFILE;
38892
- case PROFILE_NAME_HRW:
38893
- return HRW_PROFILE;
38894
- case PROFILE_NAME_STICKY_HRW:
38895
- return STICKY_HRW_PROFILE;
38896
- case PROFILE_NAME_DEVELOPMENT$1:
38897
- return DEVELOPMENT_PROFILE$1;
38898
- default:
38899
- throw new Error(`Unknown load balancing profile: ${profile}`);
38951
+ const strategyConfig = getProfile(LOAD_BALANCING_STRATEGY_FACTORY_BASE, profile);
38952
+ if (!strategyConfig) {
38953
+ throw new Error(`Unknown load balancing profile: ${profile}`);
38900
38954
  }
38955
+ return strategyConfig;
38901
38956
  }
38902
38957
  }
38903
38958
 
@@ -39066,13 +39121,11 @@ const HYBRID_ONLY_PROFILE = {
39066
39121
  type: 'HybridPathRoutingPolicy',
39067
39122
  loadBalancingStrategy: { type: 'HRWLoadBalancingStrategy' },
39068
39123
  };
39069
- const PROFILE_MAP$1 = {
39070
- [PROFILE_NAME_DEVELOPMENT]: DEVELOPMENT_PROFILE,
39071
- [PROFILE_NAME_PRODUCTION]: PRODUCTION_PROFILE,
39072
- [PROFILE_NAME_BASIC]: BASIC_PROFILE,
39073
- [PROFILE_NAME_CAPABILITY_AWARE]: CAPABILITY_AWARE_PROFILE,
39074
- [PROFILE_NAME_HYBRID_ONLY]: HYBRID_ONLY_PROFILE,
39075
- };
39124
+ registerProfile(ROUTING_POLICY_FACTORY_BASE, PROFILE_NAME_DEVELOPMENT, DEVELOPMENT_PROFILE, { source: 'routing-profile-factory' });
39125
+ registerProfile(ROUTING_POLICY_FACTORY_BASE, PROFILE_NAME_PRODUCTION, PRODUCTION_PROFILE, { source: 'routing-profile-factory' });
39126
+ registerProfile(ROUTING_POLICY_FACTORY_BASE, PROFILE_NAME_BASIC, BASIC_PROFILE, { source: 'routing-profile-factory' });
39127
+ registerProfile(ROUTING_POLICY_FACTORY_BASE, PROFILE_NAME_CAPABILITY_AWARE, CAPABILITY_AWARE_PROFILE, { source: 'routing-profile-factory' });
39128
+ registerProfile(ROUTING_POLICY_FACTORY_BASE, PROFILE_NAME_HYBRID_ONLY, HYBRID_ONLY_PROFILE, { source: 'routing-profile-factory' });
39076
39129
  const FACTORY_META$3 = {
39077
39130
  base: ROUTING_POLICY_FACTORY_BASE,
39078
39131
  key: 'RoutingProfile',
@@ -39127,7 +39180,7 @@ class RoutingProfileFactory extends RoutingPolicyFactory {
39127
39180
  return undefined;
39128
39181
  }
39129
39182
  getProfileConfig(profile) {
39130
- const routingConfig = PROFILE_MAP$1[profile];
39183
+ const routingConfig = getProfile(ROUTING_POLICY_FACTORY_BASE, profile);
39131
39184
  if (!routingConfig) {
39132
39185
  throw new Error('Unknown routing profile');
39133
39186
  }
@@ -39677,10 +39730,8 @@ const OPEN_TELEMETRY_PROFILE = {
39677
39730
  serviceName: factory.Expressions.env(ENV_VAR_TELEMETRY_SERVICE_NAME, 'naylence-service'),
39678
39731
  headers: {},
39679
39732
  };
39680
- const PROFILE_MAP = {
39681
- [PROFILE_NAME_NOOP]: NOOP_PROFILE,
39682
- [PROFILE_NAME_OPEN_TELEMETRY]: OPEN_TELEMETRY_PROFILE,
39683
- };
39733
+ registerProfile(TRACE_EMITTER_FACTORY_BASE_TYPE, PROFILE_NAME_NOOP, NOOP_PROFILE, { source: 'trace-emitter-profile-factory' });
39734
+ registerProfile(TRACE_EMITTER_FACTORY_BASE_TYPE, PROFILE_NAME_OPEN_TELEMETRY, OPEN_TELEMETRY_PROFILE, { source: 'trace-emitter-profile-factory' });
39684
39735
  const FACTORY_META = {
39685
39736
  base: TRACE_EMITTER_FACTORY_BASE_TYPE,
39686
39737
  key: 'TraceEmitterProfile',
@@ -39749,14 +39800,11 @@ function canonicalizeProfileName(value) {
39749
39800
  return PROFILE_ALIASES[normalized] ?? normalized;
39750
39801
  }
39751
39802
  function resolveProfileConfig(profileName) {
39752
- const profile = PROFILE_MAP[profileName];
39803
+ const profile = getProfile(TRACE_EMITTER_FACTORY_BASE_TYPE, profileName);
39753
39804
  if (!profile) {
39754
39805
  throw new Error(`Unknown trace emitter profile: ${profileName}`);
39755
39806
  }
39756
- return deepClone(profile);
39757
- }
39758
- function deepClone(value) {
39759
- return JSON.parse(JSON.stringify(value));
39807
+ return profile;
39760
39808
  }
39761
39809
 
39762
39810
  var traceEmitterProfileFactory = /*#__PURE__*/Object.freeze({
@@ -44020,6 +44068,7 @@ exports.broadcastChannelGrantToConnectorConfig = broadcastChannelGrantToConnecto
44020
44068
  exports.camelToSnakeCase = camelToSnakeCase;
44021
44069
  exports.canonicalJson = canonicalJson;
44022
44070
  exports.capitalizeFirstLetter = capitalizeFirstLetter;
44071
+ exports.clearProfiles = clearProfiles;
44023
44072
  exports.color = color;
44024
44073
  exports.compareCryptoLevels = compareCryptoLevels;
44025
44074
  exports.compileGlobOnlyScopeRequirement = compileGlobOnlyScopeRequirement;
@@ -44066,6 +44115,7 @@ exports.getFameRoot = getFameRoot;
44066
44115
  exports.getKeyProvider = getKeyProvider;
44067
44116
  exports.getKeyStore = getKeyStore;
44068
44117
  exports.getLogger = getLogger;
44118
+ exports.getProfile = getProfile;
44069
44119
  exports.hasCryptoSupport = hasCryptoSupport;
44070
44120
  exports.hostnameToLogical = hostnameToLogical;
44071
44121
  exports.hostnamesToLogicals = hostnamesToLogicals;
@@ -44094,6 +44144,7 @@ exports.isTokenProvider = isTokenProvider;
44094
44144
  exports.isTokenValid = isTokenValid;
44095
44145
  exports.isWebSocketConnectionGrant = isWebSocketConnectionGrant;
44096
44146
  exports.jsonDumps = jsonDumps;
44147
+ exports.listProfiles = listProfiles;
44097
44148
  exports.logicalPatternsToDnsConstraints = logicalPatternsToDnsConstraints;
44098
44149
  exports.logicalToHostname = logicalToHostname;
44099
44150
  exports.logicalsToHostnames = logicalsToHostnames;
@@ -44128,6 +44179,7 @@ exports.prettyModel = prettyModel$1;
44128
44179
  exports.registerDefaultFactories = registerDefaultFactories;
44129
44180
  exports.registerDefaultKeyStoreFactory = registerDefaultKeyStoreFactory;
44130
44181
  exports.registerNodePlacementStrategyFactory = registerNodePlacementStrategyFactory;
44182
+ exports.registerProfile = registerProfile;
44131
44183
  exports.registerRuntimeFactories = registerRuntimeFactories;
44132
44184
  exports.requireCryptoSupport = requireCryptoSupport;
44133
44185
  exports.retryWithBackoff = retryWithBackoff;