@naylence/runtime 0.4.6 → 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.
- package/dist/browser/index.cjs +120 -107
- package/dist/browser/index.mjs +117 -108
- package/dist/cjs/naylence/fame/delivery/delivery-profile-factory.js +5 -9
- package/dist/cjs/naylence/fame/index.js +1 -0
- package/dist/cjs/naylence/fame/node/admission/admission-profile-factory.js +15 -19
- package/dist/cjs/naylence/fame/node/node-identity-policy-profile-factory.js +6 -10
- package/dist/cjs/naylence/fame/profile/index.js +8 -0
- package/dist/cjs/naylence/fame/profile/profile-registry.js +57 -0
- package/dist/cjs/naylence/fame/security/auth/authorization-profile-factory.js +9 -13
- package/dist/cjs/naylence/fame/security/node-security-profile-factory.js +9 -13
- package/dist/cjs/naylence/fame/sentinel/load-balancing/load-balancing-profile-factory.js +10 -13
- package/dist/cjs/naylence/fame/sentinel/routing-profile-factory.js +7 -8
- package/dist/cjs/naylence/fame/storage/storage-profile-factory.js +8 -12
- package/dist/cjs/naylence/fame/telemetry/trace-emitter-profile-factory.js +5 -9
- package/dist/cjs/runtime-isomorphic.js +1 -0
- package/dist/cjs/version.js +2 -2
- package/dist/esm/naylence/fame/delivery/delivery-profile-factory.js +5 -9
- package/dist/esm/naylence/fame/index.js +1 -0
- package/dist/esm/naylence/fame/node/admission/admission-profile-factory.js +15 -19
- package/dist/esm/naylence/fame/node/node-identity-policy-profile-factory.js +6 -10
- package/dist/esm/naylence/fame/profile/index.js +1 -0
- package/dist/esm/naylence/fame/profile/profile-registry.js +51 -0
- package/dist/esm/naylence/fame/security/auth/authorization-profile-factory.js +9 -13
- package/dist/esm/naylence/fame/security/node-security-profile-factory.js +9 -13
- package/dist/esm/naylence/fame/sentinel/load-balancing/load-balancing-profile-factory.js +10 -13
- package/dist/esm/naylence/fame/sentinel/routing-profile-factory.js +7 -8
- package/dist/esm/naylence/fame/storage/storage-profile-factory.js +8 -12
- package/dist/esm/naylence/fame/telemetry/trace-emitter-profile-factory.js +5 -9
- package/dist/esm/runtime-isomorphic.js +1 -0
- package/dist/esm/version.js +2 -2
- package/dist/node/index.cjs +120 -107
- package/dist/node/index.mjs +117 -108
- package/dist/node/node.cjs +123 -108
- package/dist/node/node.mjs +120 -109
- package/dist/types/naylence/fame/index.d.ts +1 -0
- package/dist/types/naylence/fame/profile/index.d.ts +2 -0
- package/dist/types/naylence/fame/profile/profile-registry.d.ts +9 -0
- package/dist/types/runtime-isomorphic.d.ts +1 -0
- package/dist/types/version.d.ts +1 -1
- package/package.json +1 -1
|
@@ -4,6 +4,7 @@ exports.AuthorizationProfileFactory = exports.FACTORY_META = exports.ENV_VAR_HMA
|
|
|
4
4
|
const factory_1 = require("@naylence/factory");
|
|
5
5
|
const logging_js_1 = require("../../util/logging.js");
|
|
6
6
|
const authorizer_factory_js_1 = require("./authorizer-factory.js");
|
|
7
|
+
const profile_registry_js_1 = require("../../profile/profile-registry.js");
|
|
7
8
|
const logger = (0, logging_js_1.getLogger)('naylence.fame.security.auth.authorization_profile_factory');
|
|
8
9
|
exports.PROFILE_NAME_DEFAULT = 'jwt';
|
|
9
10
|
exports.PROFILE_NAME_OAUTH2 = 'oauth2';
|
|
@@ -90,14 +91,12 @@ const POLICY_LOCALFILE_PROFILE = {
|
|
|
90
91
|
verifier: DEFAULT_VERIFIER_CONFIG,
|
|
91
92
|
policySource: DEFAULT_POLICY_SOURCE,
|
|
92
93
|
};
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
[exports.PROFILE_NAME_NOOP]: NOOP_PROFILE,
|
|
100
|
-
};
|
|
94
|
+
(0, profile_registry_js_1.registerProfile)(authorizer_factory_js_1.AUTHORIZER_FACTORY_BASE_TYPE, exports.PROFILE_NAME_DEFAULT, DEFAULT_PROFILE, { source: 'authorization-profile-factory' });
|
|
95
|
+
(0, profile_registry_js_1.registerProfile)(authorizer_factory_js_1.AUTHORIZER_FACTORY_BASE_TYPE, exports.PROFILE_NAME_OAUTH2, OAUTH2_PROFILE, { source: 'authorization-profile-factory' });
|
|
96
|
+
(0, profile_registry_js_1.registerProfile)(authorizer_factory_js_1.AUTHORIZER_FACTORY_BASE_TYPE, exports.PROFILE_NAME_OAUTH2_GATED, OAUTH2_GATED_PROFILE, { source: 'authorization-profile-factory' });
|
|
97
|
+
(0, profile_registry_js_1.registerProfile)(authorizer_factory_js_1.AUTHORIZER_FACTORY_BASE_TYPE, exports.PROFILE_NAME_OAUTH2_CALLBACK, OAUTH2_CALLBACK_PROFILE, { source: 'authorization-profile-factory' });
|
|
98
|
+
(0, profile_registry_js_1.registerProfile)(authorizer_factory_js_1.AUTHORIZER_FACTORY_BASE_TYPE, exports.PROFILE_NAME_POLICY_LOCALFILE, POLICY_LOCALFILE_PROFILE, { source: 'authorization-profile-factory' });
|
|
99
|
+
(0, profile_registry_js_1.registerProfile)(authorizer_factory_js_1.AUTHORIZER_FACTORY_BASE_TYPE, exports.PROFILE_NAME_NOOP, NOOP_PROFILE, { source: 'authorization-profile-factory' });
|
|
101
100
|
const PROFILE_ALIASES = {
|
|
102
101
|
jwt: exports.PROFILE_NAME_DEFAULT,
|
|
103
102
|
jwks: exports.PROFILE_NAME_DEFAULT,
|
|
@@ -217,13 +216,10 @@ function canonicalizeProfileName(value) {
|
|
|
217
216
|
return PROFILE_ALIASES[normalized] ?? normalized;
|
|
218
217
|
}
|
|
219
218
|
function resolveProfileConfig(profileName) {
|
|
220
|
-
const profile =
|
|
219
|
+
const profile = (0, profile_registry_js_1.getProfile)(authorizer_factory_js_1.AUTHORIZER_FACTORY_BASE_TYPE, profileName);
|
|
221
220
|
if (!profile) {
|
|
222
221
|
throw new Error(`Unknown authorization profile: ${profileName}`);
|
|
223
222
|
}
|
|
224
|
-
return
|
|
225
|
-
}
|
|
226
|
-
function deepClone(value) {
|
|
227
|
-
return JSON.parse(JSON.stringify(value));
|
|
223
|
+
return profile;
|
|
228
224
|
}
|
|
229
225
|
exports.default = AuthorizationProfileFactory;
|
|
@@ -4,6 +4,7 @@ exports.NodeSecurityProfileFactory = exports.FACTORY_META = exports.PROFILE_NAME
|
|
|
4
4
|
const factory_1 = require("@naylence/factory");
|
|
5
5
|
const security_manager_factory_js_1 = require("./security-manager-factory.js");
|
|
6
6
|
const logging_js_1 = require("../util/logging.js");
|
|
7
|
+
const profile_registry_js_1 = require("../profile/profile-registry.js");
|
|
7
8
|
const logger = (0, logging_js_1.getLogger)('naylence.fame.security.node_security_profile_factory');
|
|
8
9
|
exports.ENV_VAR_JWT_TRUSTED_ISSUER = 'FAME_JWT_TRUSTED_ISSUER';
|
|
9
10
|
exports.ENV_VAR_JWT_ALGORITHM = 'FAME_JWT_ALGORITHM';
|
|
@@ -271,14 +272,12 @@ const OPEN_PROFILE = {
|
|
|
271
272
|
profile: factory_1.Expressions.env(exports.ENV_VAR_AUTHORIZATION_PROFILE, 'noop'),
|
|
272
273
|
},
|
|
273
274
|
};
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
[exports.PROFILE_NAME_OPEN]: OPEN_PROFILE,
|
|
281
|
-
};
|
|
275
|
+
(0, profile_registry_js_1.registerProfile)(security_manager_factory_js_1.SECURITY_MANAGER_FACTORY_BASE_TYPE, exports.PROFILE_NAME_OVERLAY, OVERLAY_PROFILE, { source: 'node-security-profile-factory' });
|
|
276
|
+
(0, profile_registry_js_1.registerProfile)(security_manager_factory_js_1.SECURITY_MANAGER_FACTORY_BASE_TYPE, exports.PROFILE_NAME_OVERLAY_CALLBACK, OVERLAY_CALLBACK_PROFILE, { source: 'node-security-profile-factory' });
|
|
277
|
+
(0, profile_registry_js_1.registerProfile)(security_manager_factory_js_1.SECURITY_MANAGER_FACTORY_BASE_TYPE, exports.PROFILE_NAME_STRICT_OVERLAY, STRICT_OVERLAY_PROFILE, { source: 'node-security-profile-factory' });
|
|
278
|
+
(0, profile_registry_js_1.registerProfile)(security_manager_factory_js_1.SECURITY_MANAGER_FACTORY_BASE_TYPE, exports.PROFILE_NAME_GATED, GATED_PROFILE, { source: 'node-security-profile-factory' });
|
|
279
|
+
(0, profile_registry_js_1.registerProfile)(security_manager_factory_js_1.SECURITY_MANAGER_FACTORY_BASE_TYPE, exports.PROFILE_NAME_GATED_CALLBACK, GATED_CALLBACK_PROFILE, { source: 'node-security-profile-factory' });
|
|
280
|
+
(0, profile_registry_js_1.registerProfile)(security_manager_factory_js_1.SECURITY_MANAGER_FACTORY_BASE_TYPE, exports.PROFILE_NAME_OPEN, OPEN_PROFILE, { source: 'node-security-profile-factory' });
|
|
282
281
|
exports.FACTORY_META = {
|
|
283
282
|
base: security_manager_factory_js_1.SECURITY_MANAGER_FACTORY_BASE_TYPE,
|
|
284
283
|
key: 'SecurityProfile',
|
|
@@ -386,13 +385,10 @@ function normalizeProfile(config) {
|
|
|
386
385
|
return value.toLowerCase();
|
|
387
386
|
}
|
|
388
387
|
function resolveProfileConfig(profileName) {
|
|
389
|
-
const template =
|
|
388
|
+
const template = (0, profile_registry_js_1.getProfile)(security_manager_factory_js_1.SECURITY_MANAGER_FACTORY_BASE_TYPE, profileName);
|
|
390
389
|
if (!template) {
|
|
391
390
|
throw new Error(`Unknown security profile: ${profileName}`);
|
|
392
391
|
}
|
|
393
|
-
return
|
|
394
|
-
}
|
|
395
|
-
function deepClone(value) {
|
|
396
|
-
return JSON.parse(JSON.stringify(value));
|
|
392
|
+
return template;
|
|
397
393
|
}
|
|
398
394
|
exports.default = NodeSecurityProfileFactory;
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.LoadBalancingProfileFactory = exports.FACTORY_META = exports.PROFILE_NAME_DEVELOPMENT = exports.PROFILE_NAME_STICKY_HRW = exports.PROFILE_NAME_HRW = exports.PROFILE_NAME_ROUND_ROBIN = exports.PROFILE_NAME_RANDOM = void 0;
|
|
4
4
|
const factory_1 = require("@naylence/factory");
|
|
5
5
|
const logging_js_1 = require("../../util/logging.js");
|
|
6
|
+
const profile_registry_js_1 = require("../../profile/profile-registry.js");
|
|
6
7
|
const load_balancing_strategy_factory_js_1 = require("./load-balancing-strategy-factory.js");
|
|
7
8
|
const logger = (0, logging_js_1.getLogger)('naylence.fame.sentinel.load_balancing.load_balancing_profile_factory');
|
|
8
9
|
exports.PROFILE_NAME_RANDOM = 'random';
|
|
@@ -26,6 +27,11 @@ const STICKY_HRW_PROFILE = {
|
|
|
26
27
|
const DEVELOPMENT_PROFILE = {
|
|
27
28
|
type: 'RoundRobinLoadBalancingStrategy',
|
|
28
29
|
};
|
|
30
|
+
(0, profile_registry_js_1.registerProfile)(load_balancing_strategy_factory_js_1.LOAD_BALANCING_STRATEGY_FACTORY_BASE, exports.PROFILE_NAME_RANDOM, RANDOM_PROFILE, { source: 'load-balancing-profile-factory' });
|
|
31
|
+
(0, profile_registry_js_1.registerProfile)(load_balancing_strategy_factory_js_1.LOAD_BALANCING_STRATEGY_FACTORY_BASE, exports.PROFILE_NAME_ROUND_ROBIN, ROUND_ROBIN_PROFILE, { source: 'load-balancing-profile-factory' });
|
|
32
|
+
(0, profile_registry_js_1.registerProfile)(load_balancing_strategy_factory_js_1.LOAD_BALANCING_STRATEGY_FACTORY_BASE, exports.PROFILE_NAME_HRW, HRW_PROFILE, { source: 'load-balancing-profile-factory' });
|
|
33
|
+
(0, profile_registry_js_1.registerProfile)(load_balancing_strategy_factory_js_1.LOAD_BALANCING_STRATEGY_FACTORY_BASE, exports.PROFILE_NAME_STICKY_HRW, STICKY_HRW_PROFILE, { source: 'load-balancing-profile-factory' });
|
|
34
|
+
(0, profile_registry_js_1.registerProfile)(load_balancing_strategy_factory_js_1.LOAD_BALANCING_STRATEGY_FACTORY_BASE, exports.PROFILE_NAME_DEVELOPMENT, DEVELOPMENT_PROFILE, { source: 'load-balancing-profile-factory' });
|
|
29
35
|
exports.FACTORY_META = {
|
|
30
36
|
base: load_balancing_strategy_factory_js_1.LOAD_BALANCING_STRATEGY_FACTORY_BASE,
|
|
31
37
|
key: 'LoadBalancingProfile',
|
|
@@ -80,20 +86,11 @@ class LoadBalancingProfileFactory extends load_balancing_strategy_factory_js_1.L
|
|
|
80
86
|
return undefined;
|
|
81
87
|
}
|
|
82
88
|
resolveProfile(profile) {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
case exports.PROFILE_NAME_ROUND_ROBIN:
|
|
87
|
-
return ROUND_ROBIN_PROFILE;
|
|
88
|
-
case exports.PROFILE_NAME_HRW:
|
|
89
|
-
return HRW_PROFILE;
|
|
90
|
-
case exports.PROFILE_NAME_STICKY_HRW:
|
|
91
|
-
return STICKY_HRW_PROFILE;
|
|
92
|
-
case exports.PROFILE_NAME_DEVELOPMENT:
|
|
93
|
-
return DEVELOPMENT_PROFILE;
|
|
94
|
-
default:
|
|
95
|
-
throw new Error(`Unknown load balancing profile: ${profile}`);
|
|
89
|
+
const strategyConfig = (0, profile_registry_js_1.getProfile)(load_balancing_strategy_factory_js_1.LOAD_BALANCING_STRATEGY_FACTORY_BASE, profile);
|
|
90
|
+
if (!strategyConfig) {
|
|
91
|
+
throw new Error(`Unknown load balancing profile: ${profile}`);
|
|
96
92
|
}
|
|
93
|
+
return strategyConfig;
|
|
97
94
|
}
|
|
98
95
|
}
|
|
99
96
|
exports.LoadBalancingProfileFactory = LoadBalancingProfileFactory;
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.RoutingProfileFactory = exports.FACTORY_META = exports.PROFILE_NAME_HYBRID_ONLY = exports.PROFILE_NAME_CAPABILITY_AWARE = exports.PROFILE_NAME_BASIC = exports.PROFILE_NAME_PRODUCTION = exports.PROFILE_NAME_DEVELOPMENT = void 0;
|
|
4
4
|
const factory_1 = require("@naylence/factory");
|
|
5
5
|
const logging_js_1 = require("../util/logging.js");
|
|
6
|
+
const profile_registry_js_1 = require("../profile/profile-registry.js");
|
|
6
7
|
const routing_policy_js_1 = require("./routing-policy.js");
|
|
7
8
|
const logger = (0, logging_js_1.getLogger)('naylence.fame.sentinel.routing_profile_factory');
|
|
8
9
|
exports.PROFILE_NAME_DEVELOPMENT = 'development';
|
|
@@ -37,13 +38,11 @@ const HYBRID_ONLY_PROFILE = {
|
|
|
37
38
|
type: 'HybridPathRoutingPolicy',
|
|
38
39
|
loadBalancingStrategy: { type: 'HRWLoadBalancingStrategy' },
|
|
39
40
|
};
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
[exports.PROFILE_NAME_HYBRID_ONLY]: HYBRID_ONLY_PROFILE,
|
|
46
|
-
};
|
|
41
|
+
(0, profile_registry_js_1.registerProfile)(routing_policy_js_1.ROUTING_POLICY_FACTORY_BASE, exports.PROFILE_NAME_DEVELOPMENT, DEVELOPMENT_PROFILE, { source: 'routing-profile-factory' });
|
|
42
|
+
(0, profile_registry_js_1.registerProfile)(routing_policy_js_1.ROUTING_POLICY_FACTORY_BASE, exports.PROFILE_NAME_PRODUCTION, PRODUCTION_PROFILE, { source: 'routing-profile-factory' });
|
|
43
|
+
(0, profile_registry_js_1.registerProfile)(routing_policy_js_1.ROUTING_POLICY_FACTORY_BASE, exports.PROFILE_NAME_BASIC, BASIC_PROFILE, { source: 'routing-profile-factory' });
|
|
44
|
+
(0, profile_registry_js_1.registerProfile)(routing_policy_js_1.ROUTING_POLICY_FACTORY_BASE, exports.PROFILE_NAME_CAPABILITY_AWARE, CAPABILITY_AWARE_PROFILE, { source: 'routing-profile-factory' });
|
|
45
|
+
(0, profile_registry_js_1.registerProfile)(routing_policy_js_1.ROUTING_POLICY_FACTORY_BASE, exports.PROFILE_NAME_HYBRID_ONLY, HYBRID_ONLY_PROFILE, { source: 'routing-profile-factory' });
|
|
47
46
|
exports.FACTORY_META = {
|
|
48
47
|
base: routing_policy_js_1.ROUTING_POLICY_FACTORY_BASE,
|
|
49
48
|
key: 'RoutingProfile',
|
|
@@ -98,7 +97,7 @@ class RoutingProfileFactory extends routing_policy_js_1.RoutingPolicyFactory {
|
|
|
98
97
|
return undefined;
|
|
99
98
|
}
|
|
100
99
|
getProfileConfig(profile) {
|
|
101
|
-
const routingConfig =
|
|
100
|
+
const routingConfig = (0, profile_registry_js_1.getProfile)(routing_policy_js_1.ROUTING_POLICY_FACTORY_BASE, profile);
|
|
102
101
|
if (!routingConfig) {
|
|
103
102
|
throw new Error('Unknown routing profile');
|
|
104
103
|
}
|
|
@@ -5,6 +5,7 @@ exports.registerStorageProfile = registerStorageProfile;
|
|
|
5
5
|
const zod_1 = require("zod");
|
|
6
6
|
const factory_1 = require("@naylence/factory");
|
|
7
7
|
const storage_provider_factory_js_1 = require("./storage-provider-factory.js");
|
|
8
|
+
const profile_registry_js_1 = require("../profile/profile-registry.js");
|
|
8
9
|
const ENV_VAR_STORAGE_DB_DIRECTORY = 'FAME_STORAGE_DB_DIRECTORY';
|
|
9
10
|
const ENV_VAR_STORAGE_MASTER_KEY = 'FAME_STORAGE_MASTER_KEY';
|
|
10
11
|
const ENV_VAR_STORAGE_ENCRYPTED = 'FAME_STORAGE_ENCRYPTED';
|
|
@@ -41,18 +42,13 @@ const ENCRYPTED_SQLITE_PROFILE_CONFIG = {
|
|
|
41
42
|
masterKey: factory_1.Expressions.env(ENV_VAR_STORAGE_MASTER_KEY),
|
|
42
43
|
isCached: true,
|
|
43
44
|
};
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
[PROFILE_NAME_MEMORY]: MEMORY_PROFILE_CONFIG,
|
|
47
|
-
[PROFILE_NAME_INDEXEDDB]: INDEXEDDB_PROFILE_CONFIG,
|
|
48
|
-
};
|
|
49
|
-
// Extended profile map - can be augmented by Node.js environment
|
|
50
|
-
const PROFILE_MAP = {
|
|
51
|
-
...BASE_PROFILE_MAP,
|
|
52
|
-
};
|
|
45
|
+
(0, profile_registry_js_1.registerProfile)(storage_provider_factory_js_1.STORAGE_PROVIDER_FACTORY_BASE_TYPE, PROFILE_NAME_MEMORY, MEMORY_PROFILE_CONFIG, { source: 'storage-profile-factory' });
|
|
46
|
+
(0, profile_registry_js_1.registerProfile)(storage_provider_factory_js_1.STORAGE_PROVIDER_FACTORY_BASE_TYPE, PROFILE_NAME_INDEXEDDB, INDEXEDDB_PROFILE_CONFIG, { source: 'storage-profile-factory' });
|
|
53
47
|
// Function to register additional profiles (used by Node.js build)
|
|
54
48
|
function registerStorageProfile(name, config) {
|
|
55
|
-
|
|
49
|
+
(0, profile_registry_js_1.registerProfile)(storage_provider_factory_js_1.STORAGE_PROVIDER_FACTORY_BASE_TYPE, name, config, {
|
|
50
|
+
source: 'storage-profile-factory',
|
|
51
|
+
});
|
|
56
52
|
}
|
|
57
53
|
// Export the SQLite configs so they can be registered from node-index.ts
|
|
58
54
|
exports.SQLITE_PROFILES = {
|
|
@@ -71,9 +67,9 @@ class StorageProfileFactory extends storage_provider_factory_js_1.StorageProvide
|
|
|
71
67
|
type: 'StorageProfile',
|
|
72
68
|
});
|
|
73
69
|
const profileName = (parsed.profile ?? PROFILE_NAME_MEMORY).toLowerCase();
|
|
74
|
-
const profileConfig =
|
|
70
|
+
const profileConfig = (0, profile_registry_js_1.getProfile)(storage_provider_factory_js_1.STORAGE_PROVIDER_FACTORY_BASE_TYPE, profileName);
|
|
75
71
|
if (!profileConfig) {
|
|
76
|
-
throw new Error(`Unknown storage profile '${profileName}'. Supported profiles: ${
|
|
72
|
+
throw new Error(`Unknown storage profile '${profileName}'. Supported profiles: ${(0, profile_registry_js_1.listProfiles)(storage_provider_factory_js_1.STORAGE_PROVIDER_FACTORY_BASE_TYPE).join(', ')}`);
|
|
77
73
|
}
|
|
78
74
|
const createOptions = {
|
|
79
75
|
...options,
|
|
@@ -4,6 +4,7 @@ exports.TraceEmitterProfileFactory = exports.FACTORY_META = exports.PROFILE_NAME
|
|
|
4
4
|
const factory_1 = require("@naylence/factory");
|
|
5
5
|
const logging_js_1 = require("../util/logging.js");
|
|
6
6
|
const trace_emitter_factory_js_1 = require("./trace-emitter-factory.js");
|
|
7
|
+
const profile_registry_js_1 = require("../profile/profile-registry.js");
|
|
7
8
|
const logger = (0, logging_js_1.getLogger)('naylence.fame.telemetry.trace_emitter_profile_factory');
|
|
8
9
|
exports.PROFILE_NAME_NOOP = 'noop';
|
|
9
10
|
exports.PROFILE_NAME_OPEN_TELEMETRY = 'open-telemetry';
|
|
@@ -16,10 +17,8 @@ const OPEN_TELEMETRY_PROFILE = {
|
|
|
16
17
|
serviceName: factory_1.Expressions.env(ENV_VAR_TELEMETRY_SERVICE_NAME, 'naylence-service'),
|
|
17
18
|
headers: {},
|
|
18
19
|
};
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
[exports.PROFILE_NAME_OPEN_TELEMETRY]: OPEN_TELEMETRY_PROFILE,
|
|
22
|
-
};
|
|
20
|
+
(0, profile_registry_js_1.registerProfile)(trace_emitter_factory_js_1.TRACE_EMITTER_FACTORY_BASE_TYPE, exports.PROFILE_NAME_NOOP, NOOP_PROFILE, { source: 'trace-emitter-profile-factory' });
|
|
21
|
+
(0, profile_registry_js_1.registerProfile)(trace_emitter_factory_js_1.TRACE_EMITTER_FACTORY_BASE_TYPE, exports.PROFILE_NAME_OPEN_TELEMETRY, OPEN_TELEMETRY_PROFILE, { source: 'trace-emitter-profile-factory' });
|
|
23
22
|
exports.FACTORY_META = {
|
|
24
23
|
base: trace_emitter_factory_js_1.TRACE_EMITTER_FACTORY_BASE_TYPE,
|
|
25
24
|
key: 'TraceEmitterProfile',
|
|
@@ -89,13 +88,10 @@ function canonicalizeProfileName(value) {
|
|
|
89
88
|
return PROFILE_ALIASES[normalized] ?? normalized;
|
|
90
89
|
}
|
|
91
90
|
function resolveProfileConfig(profileName) {
|
|
92
|
-
const profile =
|
|
91
|
+
const profile = (0, profile_registry_js_1.getProfile)(trace_emitter_factory_js_1.TRACE_EMITTER_FACTORY_BASE_TYPE, profileName);
|
|
93
92
|
if (!profile) {
|
|
94
93
|
throw new Error(`Unknown trace emitter profile: ${profileName}`);
|
|
95
94
|
}
|
|
96
|
-
return
|
|
97
|
-
}
|
|
98
|
-
function deepClone(value) {
|
|
99
|
-
return JSON.parse(JSON.stringify(value));
|
|
95
|
+
return profile;
|
|
100
96
|
}
|
|
101
97
|
exports.default = TraceEmitterProfileFactory;
|
|
@@ -19,6 +19,7 @@ Object.defineProperty(exports, "VERSION", { enumerable: true, get: function () {
|
|
|
19
19
|
tslib_1.__exportStar(require("./naylence/fame/errors/index.js"), exports);
|
|
20
20
|
tslib_1.__exportStar(require("./naylence/fame/util/index.js"), exports);
|
|
21
21
|
tslib_1.__exportStar(require("./naylence/fame/channel/index.js"), exports);
|
|
22
|
+
tslib_1.__exportStar(require("./naylence/fame/profile/index.js"), exports);
|
|
22
23
|
// Storage providers that are safe for browsers (in-memory + IndexedDB)
|
|
23
24
|
tslib_1.__exportStar(require("./naylence/fame/storage/index.js"), exports);
|
|
24
25
|
// Node lifecycle and context (Fame "Node" abstraction, not Node.js)
|
package/dist/cjs/version.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// This file is auto-generated during build - do not edit manually
|
|
3
|
-
// Generated from package.json version: 0.4.
|
|
3
|
+
// Generated from package.json version: 0.4.7
|
|
4
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
5
|
exports.VERSION = void 0;
|
|
6
6
|
/**
|
|
7
7
|
* The package version, injected at build time.
|
|
8
8
|
* @internal
|
|
9
9
|
*/
|
|
10
|
-
exports.VERSION = '0.4.
|
|
10
|
+
exports.VERSION = '0.4.7';
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Expressions } from '@naylence/factory';
|
|
2
2
|
import { DELIVERY_POLICY_FACTORY_BASE_TYPE, DeliveryPolicyFactory, } from './delivery-policy-factory.js';
|
|
3
3
|
import { getLogger } from '../util/logging.js';
|
|
4
|
+
import { getProfile, registerProfile, } from '../profile/profile-registry.js';
|
|
4
5
|
const logger = getLogger('naylence.fame.delivery.delivery_profile_factory');
|
|
5
6
|
export const PROFILE_NAME_AT_LEAST_ONCE = 'at-least-once';
|
|
6
7
|
export const PROFILE_NAME_AT_MOST_ONCE = 'at-most-once';
|
|
@@ -29,10 +30,8 @@ const AT_LEAST_ONCE_PROFILE = {
|
|
|
29
30
|
const AT_MOST_ONCE_PROFILE = {
|
|
30
31
|
type: 'AtMostOnceDeliveryPolicy',
|
|
31
32
|
};
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
[PROFILE_NAME_AT_MOST_ONCE]: AT_MOST_ONCE_PROFILE,
|
|
35
|
-
};
|
|
33
|
+
registerProfile(DELIVERY_POLICY_FACTORY_BASE_TYPE, PROFILE_NAME_AT_LEAST_ONCE, AT_LEAST_ONCE_PROFILE, { source: 'delivery-profile-factory' });
|
|
34
|
+
registerProfile(DELIVERY_POLICY_FACTORY_BASE_TYPE, PROFILE_NAME_AT_MOST_ONCE, AT_MOST_ONCE_PROFILE, { source: 'delivery-profile-factory' });
|
|
36
35
|
export class DeliveryProfileFactory extends DeliveryPolicyFactory {
|
|
37
36
|
constructor() {
|
|
38
37
|
super(...arguments);
|
|
@@ -81,14 +80,11 @@ function coerceProfileString(value) {
|
|
|
81
80
|
return trimmed.length > 0 ? trimmed : null;
|
|
82
81
|
}
|
|
83
82
|
function resolveProfileConfig(profileName) {
|
|
84
|
-
const profile =
|
|
83
|
+
const profile = getProfile(DELIVERY_POLICY_FACTORY_BASE_TYPE, profileName);
|
|
85
84
|
if (!profile) {
|
|
86
85
|
throw new Error(`Unknown delivery profile: ${profileName}`);
|
|
87
86
|
}
|
|
88
|
-
return
|
|
89
|
-
}
|
|
90
|
-
function deepClone(value) {
|
|
91
|
-
return JSON.parse(JSON.stringify(value));
|
|
87
|
+
return profile;
|
|
92
88
|
}
|
|
93
89
|
export const FACTORY_META = {
|
|
94
90
|
base: DELIVERY_POLICY_FACTORY_BASE_TYPE,
|
|
@@ -7,6 +7,7 @@ export * from './node/index.js';
|
|
|
7
7
|
export * from './delivery/index.js';
|
|
8
8
|
export * from './security/index.js';
|
|
9
9
|
export * from './storage/index.js';
|
|
10
|
+
export * from './profile/index.js';
|
|
10
11
|
export * from './util/index.js';
|
|
11
12
|
export * from './constants/index.js';
|
|
12
13
|
export * from './stickiness/index.js';
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Expressions } from '@naylence/factory';
|
|
2
2
|
import { GRANT_PURPOSE_NODE_ATTACH } from '../../grants/grant.js';
|
|
3
3
|
import { getLogger } from '../../util/logging.js';
|
|
4
|
+
import { getProfile, registerProfile, } from '../../profile/profile-registry.js';
|
|
4
5
|
import { ADMISSION_CLIENT_FACTORY_BASE_TYPE, AdmissionClientFactory, } from './admission-client-factory.js';
|
|
5
6
|
const logger = getLogger('naylence.fame.node.admission.admission_profile_factory');
|
|
6
7
|
const ENV_VAR_IS_ROOT = 'FAME_ROOT';
|
|
@@ -211,20 +212,18 @@ const NOOP_PROFILE = {
|
|
|
211
212
|
auto_accept_logicals: true,
|
|
212
213
|
autoAcceptLogicals: true,
|
|
213
214
|
};
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
[PROFILE_NAME_NONE]: NOOP_PROFILE,
|
|
227
|
-
};
|
|
215
|
+
registerProfile(ADMISSION_CLIENT_FACTORY_BASE_TYPE, PROFILE_NAME_WELCOME, WELCOME_SERVICE_PROFILE, { source: 'admission-profile-factory' });
|
|
216
|
+
registerProfile(ADMISSION_CLIENT_FACTORY_BASE_TYPE, PROFILE_NAME_WELCOME_PKCE, WELCOME_SERVICE_PKCE_PROFILE, { source: 'admission-profile-factory' });
|
|
217
|
+
registerProfile(ADMISSION_CLIENT_FACTORY_BASE_TYPE, PROFILE_NAME_WELCOME_PKCE_ALIAS, WELCOME_SERVICE_PKCE_PROFILE, { source: 'admission-profile-factory' });
|
|
218
|
+
registerProfile(ADMISSION_CLIENT_FACTORY_BASE_TYPE, PROFILE_NAME_DIRECT, DIRECT_PROFILE, { source: 'admission-profile-factory' });
|
|
219
|
+
registerProfile(ADMISSION_CLIENT_FACTORY_BASE_TYPE, PROFILE_NAME_DIRECT_PKCE, DIRECT_PKCE_PROFILE, { source: 'admission-profile-factory' });
|
|
220
|
+
registerProfile(ADMISSION_CLIENT_FACTORY_BASE_TYPE, PROFILE_NAME_DIRECT_PKCE_ALIAS, DIRECT_PKCE_PROFILE, { source: 'admission-profile-factory' });
|
|
221
|
+
registerProfile(ADMISSION_CLIENT_FACTORY_BASE_TYPE, PROFILE_NAME_DIRECT_HTTP, DIRECT_HTTP_PROFILE, { source: 'admission-profile-factory' });
|
|
222
|
+
registerProfile(ADMISSION_CLIENT_FACTORY_BASE_TYPE, PROFILE_NAME_DIRECT_INPAGE, DIRECT_INPAGE_PROFILE, { source: 'admission-profile-factory' });
|
|
223
|
+
registerProfile(ADMISSION_CLIENT_FACTORY_BASE_TYPE, PROFILE_NAME_DIRECT_INPAGE_ALIAS, DIRECT_INPAGE_PROFILE, { source: 'admission-profile-factory' });
|
|
224
|
+
registerProfile(ADMISSION_CLIENT_FACTORY_BASE_TYPE, PROFILE_NAME_OPEN, OPEN_PROFILE, { source: 'admission-profile-factory' });
|
|
225
|
+
registerProfile(ADMISSION_CLIENT_FACTORY_BASE_TYPE, PROFILE_NAME_NOOP, NOOP_PROFILE, { source: 'admission-profile-factory' });
|
|
226
|
+
registerProfile(ADMISSION_CLIENT_FACTORY_BASE_TYPE, PROFILE_NAME_NONE, NOOP_PROFILE, { source: 'admission-profile-factory' });
|
|
228
227
|
export const FACTORY_META = {
|
|
229
228
|
base: ADMISSION_CLIENT_FACTORY_BASE_TYPE,
|
|
230
229
|
key: 'AdmissionProfile',
|
|
@@ -261,13 +260,10 @@ function normalizeConfig(config) {
|
|
|
261
260
|
return { profile: normalizedProfile };
|
|
262
261
|
}
|
|
263
262
|
function resolveProfileConfig(profileName) {
|
|
264
|
-
const profile =
|
|
263
|
+
const profile = getProfile(ADMISSION_CLIENT_FACTORY_BASE_TYPE, profileName);
|
|
265
264
|
if (!profile) {
|
|
266
265
|
throw new Error(`Unknown admission profile: ${profileName}`);
|
|
267
266
|
}
|
|
268
|
-
return
|
|
269
|
-
}
|
|
270
|
-
function deepClone(value) {
|
|
271
|
-
return JSON.parse(JSON.stringify(value));
|
|
267
|
+
return profile;
|
|
272
268
|
}
|
|
273
269
|
export default AdmissionProfileFactory;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { NODE_IDENTITY_POLICY_FACTORY_BASE_TYPE, NodeIdentityPolicyFactory, } from './node-identity-policy-factory.js';
|
|
2
2
|
import { getLogger } from '../util/logging.js';
|
|
3
|
+
import { getProfile, registerProfile, } from '../profile/profile-registry.js';
|
|
3
4
|
const logger = getLogger('naylence.fame.node.node_identity_policy_profile_factory');
|
|
4
5
|
const PROFILE_NAME_DEFAULT = 'default';
|
|
5
6
|
const PROFILE_NAME_TOKEN_SUBJECT = 'token-subject';
|
|
@@ -10,11 +11,9 @@ const DEFAULT_PROFILE = {
|
|
|
10
11
|
const TOKEN_SUBJECT_PROFILE = {
|
|
11
12
|
type: 'TokenSubjectNodeIdentityPolicy',
|
|
12
13
|
};
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
[PROFILE_NAME_TOKEN_SUBJECT_ALIAS]: TOKEN_SUBJECT_PROFILE,
|
|
17
|
-
};
|
|
14
|
+
registerProfile(NODE_IDENTITY_POLICY_FACTORY_BASE_TYPE, PROFILE_NAME_DEFAULT, DEFAULT_PROFILE, { source: 'node-identity-policy-profile-factory' });
|
|
15
|
+
registerProfile(NODE_IDENTITY_POLICY_FACTORY_BASE_TYPE, PROFILE_NAME_TOKEN_SUBJECT, TOKEN_SUBJECT_PROFILE, { source: 'node-identity-policy-profile-factory' });
|
|
16
|
+
registerProfile(NODE_IDENTITY_POLICY_FACTORY_BASE_TYPE, PROFILE_NAME_TOKEN_SUBJECT_ALIAS, TOKEN_SUBJECT_PROFILE, { source: 'node-identity-policy-profile-factory' });
|
|
18
17
|
export const FACTORY_META = {
|
|
19
18
|
base: NODE_IDENTITY_POLICY_FACTORY_BASE_TYPE,
|
|
20
19
|
key: 'NodeIdentityPolicyProfile',
|
|
@@ -51,13 +50,10 @@ function normalizeConfig(config) {
|
|
|
51
50
|
return { profile: normalizedProfile };
|
|
52
51
|
}
|
|
53
52
|
function resolveProfileConfig(profileName) {
|
|
54
|
-
const profile =
|
|
53
|
+
const profile = getProfile(NODE_IDENTITY_POLICY_FACTORY_BASE_TYPE, profileName);
|
|
55
54
|
if (!profile) {
|
|
56
55
|
throw new Error(`Unknown node identity policy profile: ${profileName}`);
|
|
57
56
|
}
|
|
58
|
-
return
|
|
59
|
-
}
|
|
60
|
-
function deepClone(value) {
|
|
61
|
-
return JSON.parse(JSON.stringify(value));
|
|
57
|
+
return profile;
|
|
62
58
|
}
|
|
63
59
|
export default NodeIdentityPolicyProfileFactory;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { registerProfile, getProfile, listProfiles, clearProfiles, } from './profile-registry.js';
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
const registry = new Map();
|
|
2
|
+
function normalizeKey(value, label) {
|
|
3
|
+
if (typeof value !== 'string') {
|
|
4
|
+
throw new Error(`${label} must be a non-empty string`);
|
|
5
|
+
}
|
|
6
|
+
const trimmed = value.trim();
|
|
7
|
+
if (!trimmed) {
|
|
8
|
+
throw new Error(`${label} must be a non-empty string`);
|
|
9
|
+
}
|
|
10
|
+
return trimmed;
|
|
11
|
+
}
|
|
12
|
+
function cloneConfig(value) {
|
|
13
|
+
return JSON.parse(JSON.stringify(value));
|
|
14
|
+
}
|
|
15
|
+
export function registerProfile(baseType, name, config, options) {
|
|
16
|
+
const normalizedBase = normalizeKey(baseType, 'baseType');
|
|
17
|
+
const normalizedName = normalizeKey(name, 'profile name');
|
|
18
|
+
if (!config || typeof config !== 'object' || Array.isArray(config)) {
|
|
19
|
+
throw new Error(`Profile '${normalizedName}' config must be an object`);
|
|
20
|
+
}
|
|
21
|
+
const profiles = registry.get(normalizedBase) ?? new Map();
|
|
22
|
+
if (profiles.has(normalizedName) && options?.allowOverride !== true) {
|
|
23
|
+
const sourceLabel = options?.source ? ` (${options.source})` : '';
|
|
24
|
+
throw new Error(`Profile '${normalizedName}' already registered for ${normalizedBase}${sourceLabel}`);
|
|
25
|
+
}
|
|
26
|
+
profiles.set(normalizedName, config);
|
|
27
|
+
registry.set(normalizedBase, profiles);
|
|
28
|
+
}
|
|
29
|
+
export function getProfile(baseType, name) {
|
|
30
|
+
const normalizedBase = normalizeKey(baseType, 'baseType');
|
|
31
|
+
const normalizedName = normalizeKey(name, 'profile name');
|
|
32
|
+
const profiles = registry.get(normalizedBase);
|
|
33
|
+
if (!profiles) {
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
const profile = profiles.get(normalizedName);
|
|
37
|
+
return profile ? cloneConfig(profile) : null;
|
|
38
|
+
}
|
|
39
|
+
export function listProfiles(baseType) {
|
|
40
|
+
const normalizedBase = normalizeKey(baseType, 'baseType');
|
|
41
|
+
const profiles = registry.get(normalizedBase);
|
|
42
|
+
return profiles ? Array.from(profiles.keys()) : [];
|
|
43
|
+
}
|
|
44
|
+
export function clearProfiles(baseType) {
|
|
45
|
+
if (!baseType) {
|
|
46
|
+
registry.clear();
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
const normalizedBase = normalizeKey(baseType, 'baseType');
|
|
50
|
+
registry.delete(normalizedBase);
|
|
51
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Expressions, configValidator } from '@naylence/factory';
|
|
2
2
|
import { getLogger } from '../../util/logging.js';
|
|
3
3
|
import { AUTHORIZER_FACTORY_BASE_TYPE, AuthorizerFactory, } from './authorizer-factory.js';
|
|
4
|
+
import { getProfile, registerProfile, } from '../../profile/profile-registry.js';
|
|
4
5
|
const logger = getLogger('naylence.fame.security.auth.authorization_profile_factory');
|
|
5
6
|
export const PROFILE_NAME_DEFAULT = 'jwt';
|
|
6
7
|
export const PROFILE_NAME_OAUTH2 = 'oauth2';
|
|
@@ -87,14 +88,12 @@ const POLICY_LOCALFILE_PROFILE = {
|
|
|
87
88
|
verifier: DEFAULT_VERIFIER_CONFIG,
|
|
88
89
|
policySource: DEFAULT_POLICY_SOURCE,
|
|
89
90
|
};
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
[PROFILE_NAME_NOOP]: NOOP_PROFILE,
|
|
97
|
-
};
|
|
91
|
+
registerProfile(AUTHORIZER_FACTORY_BASE_TYPE, PROFILE_NAME_DEFAULT, DEFAULT_PROFILE, { source: 'authorization-profile-factory' });
|
|
92
|
+
registerProfile(AUTHORIZER_FACTORY_BASE_TYPE, PROFILE_NAME_OAUTH2, OAUTH2_PROFILE, { source: 'authorization-profile-factory' });
|
|
93
|
+
registerProfile(AUTHORIZER_FACTORY_BASE_TYPE, PROFILE_NAME_OAUTH2_GATED, OAUTH2_GATED_PROFILE, { source: 'authorization-profile-factory' });
|
|
94
|
+
registerProfile(AUTHORIZER_FACTORY_BASE_TYPE, PROFILE_NAME_OAUTH2_CALLBACK, OAUTH2_CALLBACK_PROFILE, { source: 'authorization-profile-factory' });
|
|
95
|
+
registerProfile(AUTHORIZER_FACTORY_BASE_TYPE, PROFILE_NAME_POLICY_LOCALFILE, POLICY_LOCALFILE_PROFILE, { source: 'authorization-profile-factory' });
|
|
96
|
+
registerProfile(AUTHORIZER_FACTORY_BASE_TYPE, PROFILE_NAME_NOOP, NOOP_PROFILE, { source: 'authorization-profile-factory' });
|
|
98
97
|
const PROFILE_ALIASES = {
|
|
99
98
|
jwt: PROFILE_NAME_DEFAULT,
|
|
100
99
|
jwks: PROFILE_NAME_DEFAULT,
|
|
@@ -213,13 +212,10 @@ function canonicalizeProfileName(value) {
|
|
|
213
212
|
return PROFILE_ALIASES[normalized] ?? normalized;
|
|
214
213
|
}
|
|
215
214
|
function resolveProfileConfig(profileName) {
|
|
216
|
-
const profile =
|
|
215
|
+
const profile = getProfile(AUTHORIZER_FACTORY_BASE_TYPE, profileName);
|
|
217
216
|
if (!profile) {
|
|
218
217
|
throw new Error(`Unknown authorization profile: ${profileName}`);
|
|
219
218
|
}
|
|
220
|
-
return
|
|
221
|
-
}
|
|
222
|
-
function deepClone(value) {
|
|
223
|
-
return JSON.parse(JSON.stringify(value));
|
|
219
|
+
return profile;
|
|
224
220
|
}
|
|
225
221
|
export default AuthorizationProfileFactory;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Expressions, configValidator, createResource, } from '@naylence/factory';
|
|
2
2
|
import { SECURITY_MANAGER_FACTORY_BASE_TYPE, SecurityManagerFactory, } from './security-manager-factory.js';
|
|
3
3
|
import { getLogger } from '../util/logging.js';
|
|
4
|
+
import { getProfile, registerProfile, } from '../profile/profile-registry.js';
|
|
4
5
|
const logger = getLogger('naylence.fame.security.node_security_profile_factory');
|
|
5
6
|
export const ENV_VAR_JWT_TRUSTED_ISSUER = 'FAME_JWT_TRUSTED_ISSUER';
|
|
6
7
|
export const ENV_VAR_JWT_ALGORITHM = 'FAME_JWT_ALGORITHM';
|
|
@@ -268,14 +269,12 @@ const OPEN_PROFILE = {
|
|
|
268
269
|
profile: Expressions.env(ENV_VAR_AUTHORIZATION_PROFILE, 'noop'),
|
|
269
270
|
},
|
|
270
271
|
};
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
[PROFILE_NAME_OPEN]: OPEN_PROFILE,
|
|
278
|
-
};
|
|
272
|
+
registerProfile(SECURITY_MANAGER_FACTORY_BASE_TYPE, PROFILE_NAME_OVERLAY, OVERLAY_PROFILE, { source: 'node-security-profile-factory' });
|
|
273
|
+
registerProfile(SECURITY_MANAGER_FACTORY_BASE_TYPE, PROFILE_NAME_OVERLAY_CALLBACK, OVERLAY_CALLBACK_PROFILE, { source: 'node-security-profile-factory' });
|
|
274
|
+
registerProfile(SECURITY_MANAGER_FACTORY_BASE_TYPE, PROFILE_NAME_STRICT_OVERLAY, STRICT_OVERLAY_PROFILE, { source: 'node-security-profile-factory' });
|
|
275
|
+
registerProfile(SECURITY_MANAGER_FACTORY_BASE_TYPE, PROFILE_NAME_GATED, GATED_PROFILE, { source: 'node-security-profile-factory' });
|
|
276
|
+
registerProfile(SECURITY_MANAGER_FACTORY_BASE_TYPE, PROFILE_NAME_GATED_CALLBACK, GATED_CALLBACK_PROFILE, { source: 'node-security-profile-factory' });
|
|
277
|
+
registerProfile(SECURITY_MANAGER_FACTORY_BASE_TYPE, PROFILE_NAME_OPEN, OPEN_PROFILE, { source: 'node-security-profile-factory' });
|
|
279
278
|
export const FACTORY_META = {
|
|
280
279
|
base: SECURITY_MANAGER_FACTORY_BASE_TYPE,
|
|
281
280
|
key: 'SecurityProfile',
|
|
@@ -382,13 +381,10 @@ function normalizeProfile(config) {
|
|
|
382
381
|
return value.toLowerCase();
|
|
383
382
|
}
|
|
384
383
|
function resolveProfileConfig(profileName) {
|
|
385
|
-
const template =
|
|
384
|
+
const template = getProfile(SECURITY_MANAGER_FACTORY_BASE_TYPE, profileName);
|
|
386
385
|
if (!template) {
|
|
387
386
|
throw new Error(`Unknown security profile: ${profileName}`);
|
|
388
387
|
}
|
|
389
|
-
return
|
|
390
|
-
}
|
|
391
|
-
function deepClone(value) {
|
|
392
|
-
return JSON.parse(JSON.stringify(value));
|
|
388
|
+
return template;
|
|
393
389
|
}
|
|
394
390
|
export default NodeSecurityProfileFactory;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { createResource } from '@naylence/factory';
|
|
2
2
|
import { getLogger } from '../../util/logging.js';
|
|
3
|
+
import { getProfile, registerProfile, } from '../../profile/profile-registry.js';
|
|
3
4
|
import { LOAD_BALANCING_STRATEGY_FACTORY_BASE, LoadBalancingStrategyFactory, } from './load-balancing-strategy-factory.js';
|
|
4
5
|
const logger = getLogger('naylence.fame.sentinel.load_balancing.load_balancing_profile_factory');
|
|
5
6
|
export const PROFILE_NAME_RANDOM = 'random';
|
|
@@ -23,6 +24,11 @@ const STICKY_HRW_PROFILE = {
|
|
|
23
24
|
const DEVELOPMENT_PROFILE = {
|
|
24
25
|
type: 'RoundRobinLoadBalancingStrategy',
|
|
25
26
|
};
|
|
27
|
+
registerProfile(LOAD_BALANCING_STRATEGY_FACTORY_BASE, PROFILE_NAME_RANDOM, RANDOM_PROFILE, { source: 'load-balancing-profile-factory' });
|
|
28
|
+
registerProfile(LOAD_BALANCING_STRATEGY_FACTORY_BASE, PROFILE_NAME_ROUND_ROBIN, ROUND_ROBIN_PROFILE, { source: 'load-balancing-profile-factory' });
|
|
29
|
+
registerProfile(LOAD_BALANCING_STRATEGY_FACTORY_BASE, PROFILE_NAME_HRW, HRW_PROFILE, { source: 'load-balancing-profile-factory' });
|
|
30
|
+
registerProfile(LOAD_BALANCING_STRATEGY_FACTORY_BASE, PROFILE_NAME_STICKY_HRW, STICKY_HRW_PROFILE, { source: 'load-balancing-profile-factory' });
|
|
31
|
+
registerProfile(LOAD_BALANCING_STRATEGY_FACTORY_BASE, PROFILE_NAME_DEVELOPMENT, DEVELOPMENT_PROFILE, { source: 'load-balancing-profile-factory' });
|
|
26
32
|
export const FACTORY_META = {
|
|
27
33
|
base: LOAD_BALANCING_STRATEGY_FACTORY_BASE,
|
|
28
34
|
key: 'LoadBalancingProfile',
|
|
@@ -77,20 +83,11 @@ export class LoadBalancingProfileFactory extends LoadBalancingStrategyFactory {
|
|
|
77
83
|
return undefined;
|
|
78
84
|
}
|
|
79
85
|
resolveProfile(profile) {
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
case PROFILE_NAME_ROUND_ROBIN:
|
|
84
|
-
return ROUND_ROBIN_PROFILE;
|
|
85
|
-
case PROFILE_NAME_HRW:
|
|
86
|
-
return HRW_PROFILE;
|
|
87
|
-
case PROFILE_NAME_STICKY_HRW:
|
|
88
|
-
return STICKY_HRW_PROFILE;
|
|
89
|
-
case PROFILE_NAME_DEVELOPMENT:
|
|
90
|
-
return DEVELOPMENT_PROFILE;
|
|
91
|
-
default:
|
|
92
|
-
throw new Error(`Unknown load balancing profile: ${profile}`);
|
|
86
|
+
const strategyConfig = getProfile(LOAD_BALANCING_STRATEGY_FACTORY_BASE, profile);
|
|
87
|
+
if (!strategyConfig) {
|
|
88
|
+
throw new Error(`Unknown load balancing profile: ${profile}`);
|
|
93
89
|
}
|
|
90
|
+
return strategyConfig;
|
|
94
91
|
}
|
|
95
92
|
}
|
|
96
93
|
export default LoadBalancingProfileFactory;
|