@naylence/runtime 0.3.21 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/index.cjs +3368 -1393
- package/dist/browser/index.mjs +3324 -1387
- package/dist/cjs/naylence/fame/factory-manifest.js +8 -0
- package/dist/cjs/naylence/fame/node/node-event-listener.js +4 -0
- package/dist/cjs/naylence/fame/security/auth/authorization-profile-factory.js +165 -0
- package/dist/cjs/naylence/fame/security/auth/default-policy-authorizer-factory.js +147 -0
- package/dist/cjs/naylence/fame/security/auth/default-policy-authorizer.js +291 -0
- package/dist/cjs/naylence/fame/security/auth/oauth2-authorizer-factory.js +7 -0
- package/dist/cjs/naylence/fame/security/auth/oauth2-authorizer.js +19 -4
- package/dist/cjs/naylence/fame/security/auth/policy/authorization-policy-definition.js +60 -0
- package/dist/cjs/naylence/fame/security/auth/policy/authorization-policy-factory.js +35 -0
- package/dist/cjs/naylence/fame/security/auth/policy/authorization-policy-source-factory.js +35 -0
- package/dist/cjs/naylence/fame/security/auth/policy/authorization-policy-source.js +2 -0
- package/dist/cjs/naylence/fame/security/auth/policy/authorization-policy.js +2 -0
- package/dist/cjs/naylence/fame/security/auth/policy/basic-authorization-policy-factory.js +99 -0
- package/dist/cjs/naylence/fame/security/auth/policy/basic-authorization-policy.js +449 -0
- package/dist/cjs/naylence/fame/security/auth/policy/index.js +40 -0
- package/dist/cjs/naylence/fame/security/auth/policy/local-file-authorization-policy-source-factory.js +101 -0
- package/dist/cjs/naylence/fame/security/auth/policy/local-file-authorization-policy-source.js +164 -0
- package/dist/cjs/naylence/fame/security/auth/policy/pattern-matcher.js +195 -0
- package/dist/cjs/naylence/fame/security/auth/policy/scope-matcher.js +169 -0
- package/dist/cjs/naylence/fame/security/auth/policy-authorizer.js +2 -0
- package/dist/cjs/naylence/fame/security/default-security-manager.js +94 -0
- package/dist/cjs/naylence/fame/security/index.js +22 -1
- package/dist/cjs/naylence/fame/security/node-security-profile-factory.js +15 -73
- package/dist/cjs/naylence/fame/sentinel/router.js +67 -1
- package/dist/cjs/naylence/fame/sentinel/sentinel.js +46 -2
- package/dist/cjs/naylence/fame/util/register-runtime-factories.js +2 -0
- package/dist/cjs/version.js +2 -2
- package/dist/esm/naylence/fame/factory-manifest.js +8 -0
- package/dist/esm/naylence/fame/node/node-event-listener.js +4 -0
- package/dist/esm/naylence/fame/security/auth/authorization-profile-factory.js +161 -0
- package/dist/esm/naylence/fame/security/auth/default-policy-authorizer-factory.js +110 -0
- package/dist/esm/naylence/fame/security/auth/default-policy-authorizer.js +287 -0
- package/dist/esm/naylence/fame/security/auth/oauth2-authorizer-factory.js +7 -0
- package/dist/esm/naylence/fame/security/auth/oauth2-authorizer.js +19 -4
- package/dist/esm/naylence/fame/security/auth/policy/authorization-policy-definition.js +57 -0
- package/dist/esm/naylence/fame/security/auth/policy/authorization-policy-factory.js +31 -0
- package/dist/esm/naylence/fame/security/auth/policy/authorization-policy-source-factory.js +31 -0
- package/dist/esm/naylence/fame/security/auth/policy/authorization-policy-source.js +1 -0
- package/dist/esm/naylence/fame/security/auth/policy/authorization-policy.js +1 -0
- package/dist/esm/naylence/fame/security/auth/policy/basic-authorization-policy-factory.js +62 -0
- package/dist/esm/naylence/fame/security/auth/policy/basic-authorization-policy.js +445 -0
- package/dist/esm/naylence/fame/security/auth/policy/index.js +20 -0
- package/dist/esm/naylence/fame/security/auth/policy/local-file-authorization-policy-source-factory.js +64 -0
- package/dist/esm/naylence/fame/security/auth/policy/local-file-authorization-policy-source.js +127 -0
- package/dist/esm/naylence/fame/security/auth/policy/pattern-matcher.js +185 -0
- package/dist/esm/naylence/fame/security/auth/policy/scope-matcher.js +162 -0
- package/dist/esm/naylence/fame/security/auth/policy-authorizer.js +1 -0
- package/dist/esm/naylence/fame/security/default-security-manager.js +94 -0
- package/dist/esm/naylence/fame/security/index.js +5 -1
- package/dist/esm/naylence/fame/security/node-security-profile-factory.js +14 -72
- package/dist/esm/naylence/fame/sentinel/router.js +64 -0
- package/dist/esm/naylence/fame/sentinel/sentinel.js +47 -3
- package/dist/esm/naylence/fame/util/register-runtime-factories.js +2 -0
- package/dist/esm/version.js +2 -2
- package/dist/node/index.cjs +3364 -1389
- package/dist/node/index.mjs +3324 -1387
- package/dist/node/node.cjs +3416 -1425
- package/dist/node/node.mjs +3376 -1423
- package/dist/types/naylence/fame/factory-manifest.d.ts +1 -1
- package/dist/types/naylence/fame/node/node-event-listener.d.ts +31 -0
- package/dist/types/naylence/fame/security/auth/authorization-profile-factory.d.ts +29 -0
- package/dist/types/naylence/fame/security/auth/authorizer.d.ts +37 -0
- package/dist/types/naylence/fame/security/auth/default-policy-authorizer-factory.d.ts +55 -0
- package/dist/types/naylence/fame/security/auth/default-policy-authorizer.d.ts +99 -0
- package/dist/types/naylence/fame/security/auth/oauth2-authorizer-factory.d.ts +2 -0
- package/dist/types/naylence/fame/security/auth/oauth2-authorizer.d.ts +2 -0
- package/dist/types/naylence/fame/security/auth/policy/authorization-policy-definition.d.ts +166 -0
- package/dist/types/naylence/fame/security/auth/policy/authorization-policy-factory.d.ts +38 -0
- package/dist/types/naylence/fame/security/auth/policy/authorization-policy-source-factory.d.ts +38 -0
- package/dist/types/naylence/fame/security/auth/policy/authorization-policy-source.d.ts +20 -0
- package/dist/types/naylence/fame/security/auth/policy/authorization-policy.d.ts +55 -0
- package/dist/types/naylence/fame/security/auth/policy/basic-authorization-policy-factory.d.ts +42 -0
- package/dist/types/naylence/fame/security/auth/policy/basic-authorization-policy.d.ts +78 -0
- package/dist/types/naylence/fame/security/auth/policy/index.d.ts +19 -0
- package/dist/types/naylence/fame/security/auth/policy/local-file-authorization-policy-source-factory.d.ts +51 -0
- package/dist/types/naylence/fame/security/auth/policy/local-file-authorization-policy-source.d.ts +67 -0
- package/dist/types/naylence/fame/security/auth/policy/pattern-matcher.d.ts +84 -0
- package/dist/types/naylence/fame/security/auth/policy/scope-matcher.d.ts +61 -0
- package/dist/types/naylence/fame/security/auth/policy-authorizer.d.ts +12 -0
- package/dist/types/naylence/fame/security/default-security-manager.d.ts +22 -0
- package/dist/types/naylence/fame/security/index.d.ts +5 -1
- package/dist/types/naylence/fame/security/node-security-profile-factory.d.ts +2 -0
- package/dist/types/naylence/fame/sentinel/router.d.ts +68 -0
- package/dist/types/naylence/fame/sentinel/sentinel.d.ts +16 -0
- package/dist/types/version.d.ts +1 -1
- package/package.json +1 -1
|
@@ -87,6 +87,7 @@ class OAuth2AuthorizerFactory extends authorizer_factory_js_1.AuthorizerFactory
|
|
|
87
87
|
maxTtlSec: normalized.maxTtlSec,
|
|
88
88
|
reverseAuthTtlSec: normalized.reverseAuthTtlSec,
|
|
89
89
|
enforceTokenSubjectNodeIdentity: normalized.enforceTokenSubjectNodeIdentity,
|
|
90
|
+
trustedClientScope: normalized.trustedClientScope,
|
|
90
91
|
};
|
|
91
92
|
if (tokenIssuer) {
|
|
92
93
|
authorizerOptions.tokenIssuer = tokenIssuer;
|
|
@@ -157,6 +158,11 @@ function normalizeConfig(config) {
|
|
|
157
158
|
: ttl_constants_js_1.DEFAULT_REVERSE_AUTH_TTL_SEC;
|
|
158
159
|
const enforceTokenSubjectNodeIdentity = normalizeBooleanOption(source.enforceTokenSubjectNodeIdentity ??
|
|
159
160
|
source.enforce_token_subject_node_identity, false);
|
|
161
|
+
const trustedClientScope = typeof source.trustedClientScope === 'string'
|
|
162
|
+
? source.trustedClientScope
|
|
163
|
+
: typeof source.trusted_client_scope === 'string'
|
|
164
|
+
? source.trusted_client_scope
|
|
165
|
+
: undefined;
|
|
160
166
|
const tokenVerifierConfigInput = source.tokenVerifierConfig ?? source.token_verifier_config ?? null;
|
|
161
167
|
const tokenVerifierConfig = normalizeTokenVerifierConfig({
|
|
162
168
|
config: tokenVerifierConfigInput,
|
|
@@ -177,6 +183,7 @@ function normalizeConfig(config) {
|
|
|
177
183
|
reverseAuthTtlSec: reverseAuthCandidate,
|
|
178
184
|
enforceTokenSubjectNodeIdentity,
|
|
179
185
|
...(audience ? { audience } : {}),
|
|
186
|
+
...(trustedClientScope ? { trustedClientScope } : {}),
|
|
180
187
|
};
|
|
181
188
|
if (tokenIssuerConfig) {
|
|
182
189
|
normalized.tokenIssuerConfig = tokenIssuerConfig;
|
|
@@ -41,6 +41,10 @@ function normalizeOptions(raw) {
|
|
|
41
41
|
(typeof snake.enforce_token_subject_node_identity === 'boolean'
|
|
42
42
|
? snake.enforce_token_subject_node_identity
|
|
43
43
|
: undefined);
|
|
44
|
+
const trustedClientScope = camel.trustedClientScope ??
|
|
45
|
+
(typeof snake.trusted_client_scope === 'string'
|
|
46
|
+
? snake.trusted_client_scope
|
|
47
|
+
: undefined);
|
|
44
48
|
return {
|
|
45
49
|
tokenVerifier,
|
|
46
50
|
tokenIssuer,
|
|
@@ -51,6 +55,7 @@ function normalizeOptions(raw) {
|
|
|
51
55
|
maxTtlSec,
|
|
52
56
|
reverseAuthTtlSec,
|
|
53
57
|
enforceTokenSubjectNodeIdentity,
|
|
58
|
+
trustedClientScope,
|
|
54
59
|
};
|
|
55
60
|
}
|
|
56
61
|
class OAuth2Authorizer {
|
|
@@ -66,6 +71,7 @@ class OAuth2Authorizer {
|
|
|
66
71
|
options.reverseAuthTtlSec ?? ttl_constants_js_1.DEFAULT_REVERSE_AUTH_TTL_SEC;
|
|
67
72
|
this.enforceTokenSubjectNodeIdentity =
|
|
68
73
|
options.enforceTokenSubjectNodeIdentity ?? false;
|
|
74
|
+
this.trustedClientScope = options.trustedClientScope ?? 'node.trusted';
|
|
69
75
|
}
|
|
70
76
|
get tokenVerifier() {
|
|
71
77
|
return this.tokenVerifierImpl;
|
|
@@ -195,11 +201,20 @@ class OAuth2Authorizer {
|
|
|
195
201
|
});
|
|
196
202
|
return undefined;
|
|
197
203
|
}
|
|
198
|
-
// Enforce token subject node identity if enabled
|
|
204
|
+
// Enforce token subject node identity if enabled and not a trusted client
|
|
199
205
|
if (this.enforceTokenSubjectNodeIdentity) {
|
|
200
|
-
const
|
|
201
|
-
if (
|
|
202
|
-
|
|
206
|
+
const isTrustedClient = scopes.has(this.trustedClientScope);
|
|
207
|
+
if (isTrustedClient) {
|
|
208
|
+
logger.debug('oauth2_attach_trusted_client_bypass', {
|
|
209
|
+
system_id: frame.systemId,
|
|
210
|
+
trusted_scope: this.trustedClientScope,
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
else {
|
|
214
|
+
const validationResult = await this.validateTokenSubjectNodeIdentity(frame.systemId, claims);
|
|
215
|
+
if (!validationResult) {
|
|
216
|
+
return undefined;
|
|
217
|
+
}
|
|
203
218
|
}
|
|
204
219
|
}
|
|
205
220
|
claims.instance_id = claims.instance_id ?? frame.instanceId;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Authorization policy definition types.
|
|
4
|
+
*
|
|
5
|
+
* This module defines the schema for authorization policies that can be
|
|
6
|
+
* loaded from YAML/JSON files and evaluated at runtime.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.VALID_EFFECTS = exports.VALID_ORIGIN_TYPES = exports.VALID_ACTIONS = exports.KNOWN_RULE_FIELDS = exports.KNOWN_POLICY_FIELDS = exports.MAX_SCOPE_NESTING_DEPTH = void 0;
|
|
10
|
+
/**
|
|
11
|
+
* Maximum nesting depth for scope requirements.
|
|
12
|
+
*/
|
|
13
|
+
exports.MAX_SCOPE_NESTING_DEPTH = 5;
|
|
14
|
+
/**
|
|
15
|
+
* Known fields in AuthorizationPolicyDefinition.
|
|
16
|
+
*/
|
|
17
|
+
exports.KNOWN_POLICY_FIELDS = new Set([
|
|
18
|
+
'version',
|
|
19
|
+
'default_effect',
|
|
20
|
+
'rules',
|
|
21
|
+
]);
|
|
22
|
+
/**
|
|
23
|
+
* Known fields in AuthorizationRuleDefinition.
|
|
24
|
+
* Fields not in this set trigger a warning.
|
|
25
|
+
*/
|
|
26
|
+
exports.KNOWN_RULE_FIELDS = new Set([
|
|
27
|
+
'id',
|
|
28
|
+
'description',
|
|
29
|
+
'effect',
|
|
30
|
+
'action',
|
|
31
|
+
'address',
|
|
32
|
+
'frame_type',
|
|
33
|
+
'origin_type',
|
|
34
|
+
'scope',
|
|
35
|
+
'when', // Reserved for advanced-security
|
|
36
|
+
]);
|
|
37
|
+
/**
|
|
38
|
+
* Valid action values.
|
|
39
|
+
*/
|
|
40
|
+
exports.VALID_ACTIONS = [
|
|
41
|
+
'Connect',
|
|
42
|
+
'ForwardUpstream',
|
|
43
|
+
'ForwardDownstream',
|
|
44
|
+
'ForwardPeer',
|
|
45
|
+
'DeliverLocal',
|
|
46
|
+
'*',
|
|
47
|
+
];
|
|
48
|
+
/**
|
|
49
|
+
* Valid origin type values (lowercase, matching DeliveryOriginType string values).
|
|
50
|
+
*/
|
|
51
|
+
exports.VALID_ORIGIN_TYPES = [
|
|
52
|
+
'downstream',
|
|
53
|
+
'upstream',
|
|
54
|
+
'peer',
|
|
55
|
+
'local',
|
|
56
|
+
];
|
|
57
|
+
/**
|
|
58
|
+
* Valid effect values.
|
|
59
|
+
*/
|
|
60
|
+
exports.VALID_EFFECTS = ['allow', 'deny'];
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AuthorizationPolicyFactory = exports.AUTHORIZATION_POLICY_FACTORY_BASE_TYPE = void 0;
|
|
4
|
+
const factory_1 = require("@naylence/factory");
|
|
5
|
+
/**
|
|
6
|
+
* Base type identifier for authorization policy factories.
|
|
7
|
+
*/
|
|
8
|
+
exports.AUTHORIZATION_POLICY_FACTORY_BASE_TYPE = 'AuthorizationPolicyFactory';
|
|
9
|
+
/**
|
|
10
|
+
* Abstract factory base class for creating authorization policies.
|
|
11
|
+
*
|
|
12
|
+
* Implementations of this factory create specific types of authorization
|
|
13
|
+
* policies (e.g., expression-based, rule-based, etc.).
|
|
14
|
+
*/
|
|
15
|
+
class AuthorizationPolicyFactory extends factory_1.AbstractResourceFactory {
|
|
16
|
+
/**
|
|
17
|
+
* Static helper to create an authorization policy using the factory registry.
|
|
18
|
+
*
|
|
19
|
+
* @param config - Configuration for the policy
|
|
20
|
+
* @param options - Resource creation options
|
|
21
|
+
* @returns The created policy, or undefined if no factory matched
|
|
22
|
+
*/
|
|
23
|
+
static async createAuthorizationPolicy(config, options = {}) {
|
|
24
|
+
if (config) {
|
|
25
|
+
const policy = await (0, factory_1.createResource)(exports.AUTHORIZATION_POLICY_FACTORY_BASE_TYPE, config, options);
|
|
26
|
+
if (!policy) {
|
|
27
|
+
throw new Error('Failed to create authorization policy from configuration');
|
|
28
|
+
}
|
|
29
|
+
return policy;
|
|
30
|
+
}
|
|
31
|
+
const policy = await (0, factory_1.createDefaultResource)(exports.AUTHORIZATION_POLICY_FACTORY_BASE_TYPE, null, options);
|
|
32
|
+
return policy ?? undefined;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
exports.AuthorizationPolicyFactory = AuthorizationPolicyFactory;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AuthorizationPolicySourceFactory = exports.AUTHORIZATION_POLICY_SOURCE_FACTORY_BASE_TYPE = void 0;
|
|
4
|
+
const factory_1 = require("@naylence/factory");
|
|
5
|
+
/**
|
|
6
|
+
* Base type identifier for authorization policy source factories.
|
|
7
|
+
*/
|
|
8
|
+
exports.AUTHORIZATION_POLICY_SOURCE_FACTORY_BASE_TYPE = 'AuthorizationPolicySourceFactory';
|
|
9
|
+
/**
|
|
10
|
+
* Abstract factory base class for creating authorization policy sources.
|
|
11
|
+
*
|
|
12
|
+
* Implementations of this factory create specific types of policy sources
|
|
13
|
+
* (e.g., local file, remote store, in-memory, etc.).
|
|
14
|
+
*/
|
|
15
|
+
class AuthorizationPolicySourceFactory extends factory_1.AbstractResourceFactory {
|
|
16
|
+
/**
|
|
17
|
+
* Static helper to create an authorization policy source using the factory registry.
|
|
18
|
+
*
|
|
19
|
+
* @param config - Configuration for the policy source
|
|
20
|
+
* @param options - Resource creation options
|
|
21
|
+
* @returns The created policy source, or undefined if no factory matched
|
|
22
|
+
*/
|
|
23
|
+
static async createAuthorizationPolicySource(config, options = {}) {
|
|
24
|
+
if (config) {
|
|
25
|
+
const source = await (0, factory_1.createResource)(exports.AUTHORIZATION_POLICY_SOURCE_FACTORY_BASE_TYPE, config, options);
|
|
26
|
+
if (!source) {
|
|
27
|
+
throw new Error('Failed to create authorization policy source from configuration');
|
|
28
|
+
}
|
|
29
|
+
return source;
|
|
30
|
+
}
|
|
31
|
+
const source = await (0, factory_1.createDefaultResource)(exports.AUTHORIZATION_POLICY_SOURCE_FACTORY_BASE_TYPE, null, options);
|
|
32
|
+
return source ?? undefined;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
exports.AuthorizationPolicySourceFactory = AuthorizationPolicySourceFactory;
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Factory for creating BasicAuthorizationPolicy instances.
|
|
4
|
+
*/
|
|
5
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
8
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
9
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
10
|
+
}
|
|
11
|
+
Object.defineProperty(o, k2, desc);
|
|
12
|
+
}) : (function(o, m, k, k2) {
|
|
13
|
+
if (k2 === undefined) k2 = k;
|
|
14
|
+
o[k2] = m[k];
|
|
15
|
+
}));
|
|
16
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
17
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
18
|
+
}) : function(o, v) {
|
|
19
|
+
o["default"] = v;
|
|
20
|
+
});
|
|
21
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
22
|
+
var ownKeys = function(o) {
|
|
23
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
24
|
+
var ar = [];
|
|
25
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
26
|
+
return ar;
|
|
27
|
+
};
|
|
28
|
+
return ownKeys(o);
|
|
29
|
+
};
|
|
30
|
+
return function (mod) {
|
|
31
|
+
if (mod && mod.__esModule) return mod;
|
|
32
|
+
var result = {};
|
|
33
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
34
|
+
__setModuleDefault(result, mod);
|
|
35
|
+
return result;
|
|
36
|
+
};
|
|
37
|
+
})();
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.BasicAuthorizationPolicyFactory = exports.FACTORY_META = void 0;
|
|
40
|
+
const authorization_policy_factory_js_1 = require("./authorization-policy-factory.js");
|
|
41
|
+
/**
|
|
42
|
+
* Lazy import for tree-shaking.
|
|
43
|
+
*/
|
|
44
|
+
async function safeImportModule() {
|
|
45
|
+
return await Promise.resolve().then(() => __importStar(require('./basic-authorization-policy.js')));
|
|
46
|
+
}
|
|
47
|
+
function normalizeConfig(config) {
|
|
48
|
+
if (!config) {
|
|
49
|
+
throw new Error('BasicAuthorizationPolicyFactory requires a configuration with a policyDefinition');
|
|
50
|
+
}
|
|
51
|
+
const candidate = config;
|
|
52
|
+
// Support both camelCase and snake_case for policyDefinition
|
|
53
|
+
const policyDefinition = (candidate.policyDefinition ??
|
|
54
|
+
candidate.policy_definition);
|
|
55
|
+
if (!policyDefinition || typeof policyDefinition !== 'object') {
|
|
56
|
+
throw new Error('BasicAuthorizationPolicyConfig requires a policyDefinition object');
|
|
57
|
+
}
|
|
58
|
+
// Support both camelCase and snake_case for warnOnUnknownFields
|
|
59
|
+
const warnOnUnknownFields = candidate.warnOnUnknownFields ?? candidate.warn_on_unknown_fields;
|
|
60
|
+
if (warnOnUnknownFields !== undefined && typeof warnOnUnknownFields !== 'boolean') {
|
|
61
|
+
throw new Error('warnOnUnknownFields must be a boolean');
|
|
62
|
+
}
|
|
63
|
+
return {
|
|
64
|
+
policyDefinition,
|
|
65
|
+
warnOnUnknownFields: warnOnUnknownFields ?? true,
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Factory metadata for registration.
|
|
70
|
+
*/
|
|
71
|
+
exports.FACTORY_META = {
|
|
72
|
+
base: authorization_policy_factory_js_1.AUTHORIZATION_POLICY_FACTORY_BASE_TYPE,
|
|
73
|
+
key: 'BasicAuthorizationPolicy',
|
|
74
|
+
};
|
|
75
|
+
/**
|
|
76
|
+
* Factory for creating BasicAuthorizationPolicy instances.
|
|
77
|
+
*/
|
|
78
|
+
class BasicAuthorizationPolicyFactory extends authorization_policy_factory_js_1.AuthorizationPolicyFactory {
|
|
79
|
+
constructor() {
|
|
80
|
+
super(...arguments);
|
|
81
|
+
this.type = 'BasicAuthorizationPolicy';
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Creates a BasicAuthorizationPolicy from the given configuration.
|
|
85
|
+
*
|
|
86
|
+
* @param config - Configuration with policyDefinition
|
|
87
|
+
* @returns The created authorization policy
|
|
88
|
+
*/
|
|
89
|
+
async create(config) {
|
|
90
|
+
const normalized = normalizeConfig(config);
|
|
91
|
+
const { BasicAuthorizationPolicy } = await safeImportModule();
|
|
92
|
+
return new BasicAuthorizationPolicy({
|
|
93
|
+
policyDefinition: normalized.policyDefinition,
|
|
94
|
+
warnOnUnknownFields: normalized.warnOnUnknownFields,
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
exports.BasicAuthorizationPolicyFactory = BasicAuthorizationPolicyFactory;
|
|
99
|
+
exports.default = BasicAuthorizationPolicyFactory;
|