@naylence/advanced-security 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.
- package/dist/browser/index.cjs +503 -16
- package/dist/browser/index.mjs +504 -17
- package/dist/cjs/advanced-security-isomorphic.js +1 -1
- package/dist/cjs/advanced-security-isomorphic.js.map +1 -1
- package/dist/cjs/naylence/fame/factory-manifest.js +2 -0
- package/dist/cjs/naylence/fame/factory-manifest.js.map +1 -1
- package/dist/cjs/naylence/fame/security/auth/index.js +2 -0
- package/dist/cjs/naylence/fame/security/auth/index.js.map +1 -1
- package/dist/cjs/naylence/fame/security/auth/policy/auth-policy-server-cli.js +47 -0
- package/dist/cjs/naylence/fame/security/auth/policy/auth-policy-server-cli.js.map +1 -0
- package/dist/cjs/naylence/fame/security/auth/policy/auth-policy-server.js +562 -0
- package/dist/cjs/naylence/fame/security/auth/policy/auth-policy-server.js.map +1 -0
- package/dist/cjs/naylence/fame/security/auth/policy/http-authorization-policy-source-factory.js +108 -0
- package/dist/cjs/naylence/fame/security/auth/policy/http-authorization-policy-source-factory.js.map +1 -0
- package/dist/cjs/naylence/fame/security/auth/policy/http-authorization-policy-source.js +367 -0
- package/dist/cjs/naylence/fame/security/auth/policy/http-authorization-policy-source.js.map +1 -0
- package/dist/cjs/naylence/fame/security/auth/policy/index.js +4 -2
- package/dist/cjs/naylence/fame/security/auth/policy/index.js.map +1 -1
- package/dist/cjs/naylence/fame/security/auth/policy-http-authorization-profile.js +78 -0
- package/dist/cjs/naylence/fame/security/auth/policy-http-authorization-profile.js.map +1 -0
- package/dist/cjs/naylence/fame/security/register-advanced-security-factories.js +2 -0
- package/dist/cjs/naylence/fame/security/register-advanced-security-factories.js.map +1 -1
- package/dist/cjs/version.js +2 -2
- package/dist/esm/advanced-security-isomorphic.js +1 -1
- package/dist/esm/advanced-security-isomorphic.js.map +1 -1
- package/dist/esm/naylence/fame/factory-manifest.js +2 -0
- package/dist/esm/naylence/fame/factory-manifest.js.map +1 -1
- package/dist/esm/naylence/fame/security/auth/index.js +2 -0
- package/dist/esm/naylence/fame/security/auth/index.js.map +1 -1
- package/dist/esm/naylence/fame/security/auth/policy/auth-policy-server-cli.js +47 -0
- package/dist/esm/naylence/fame/security/auth/policy/auth-policy-server-cli.js.map +1 -0
- package/dist/esm/naylence/fame/security/auth/policy/auth-policy-server.js +562 -0
- package/dist/esm/naylence/fame/security/auth/policy/auth-policy-server.js.map +1 -0
- package/dist/esm/naylence/fame/security/auth/policy/http-authorization-policy-source-factory.js +108 -0
- package/dist/esm/naylence/fame/security/auth/policy/http-authorization-policy-source-factory.js.map +1 -0
- package/dist/esm/naylence/fame/security/auth/policy/http-authorization-policy-source.js +367 -0
- package/dist/esm/naylence/fame/security/auth/policy/http-authorization-policy-source.js.map +1 -0
- package/dist/esm/naylence/fame/security/auth/policy/index.js +4 -2
- package/dist/esm/naylence/fame/security/auth/policy/index.js.map +1 -1
- package/dist/esm/naylence/fame/security/auth/policy-http-authorization-profile.js +78 -0
- package/dist/esm/naylence/fame/security/auth/policy-http-authorization-profile.js.map +1 -0
- package/dist/esm/naylence/fame/security/register-advanced-security-factories.js +2 -0
- package/dist/esm/naylence/fame/security/register-advanced-security-factories.js.map +1 -1
- package/dist/esm/version.js +2 -2
- package/dist/node/index.cjs +578 -125
- package/dist/node/index.mjs +572 -94
- package/dist/node/node.cjs +589 -51
- package/dist/node/node.mjs +582 -19
- package/dist/types/advanced-security-isomorphic.d.ts +0 -1
- package/dist/types/advanced-security-isomorphic.d.ts.map +1 -1
- package/dist/types/naylence/fame/factory-manifest.d.ts +1 -1
- package/dist/types/naylence/fame/factory-manifest.d.ts.map +1 -1
- package/dist/types/naylence/fame/security/auth/index.d.ts +1 -0
- package/dist/types/naylence/fame/security/auth/index.d.ts.map +1 -1
- package/dist/types/naylence/fame/security/auth/policy/auth-policy-server-cli.d.ts +20 -0
- package/dist/types/naylence/fame/security/auth/policy/auth-policy-server-cli.d.ts.map +1 -0
- package/dist/types/naylence/fame/security/auth/policy/auth-policy-server.d.ts +75 -0
- package/dist/types/naylence/fame/security/auth/policy/auth-policy-server.d.ts.map +1 -0
- package/dist/types/naylence/fame/security/auth/policy/http-authorization-policy-source-factory.d.ts +81 -0
- package/dist/types/naylence/fame/security/auth/policy/http-authorization-policy-source-factory.d.ts.map +1 -0
- package/dist/types/naylence/fame/security/auth/policy/http-authorization-policy-source.d.ts +150 -0
- package/dist/types/naylence/fame/security/auth/policy/http-authorization-policy-source.d.ts.map +1 -0
- package/dist/types/naylence/fame/security/auth/policy/index.d.ts +2 -1
- package/dist/types/naylence/fame/security/auth/policy/index.d.ts.map +1 -1
- package/dist/types/naylence/fame/security/auth/policy-http-authorization-profile.d.ts +17 -0
- package/dist/types/naylence/fame/security/auth/policy-http-authorization-profile.d.ts.map +1 -0
- package/dist/types/naylence/fame/security/register-advanced-security-factories.d.ts +1 -0
- package/dist/types/naylence/fame/security/register-advanced-security-factories.d.ts.map +1 -1
- package/dist/types/version.d.ts +1 -1
- package/package.json +3 -2
package/dist/node/node.cjs
CHANGED
|
@@ -4,6 +4,7 @@ var factory = require('@naylence/factory');
|
|
|
4
4
|
var runtime = require('@naylence/runtime');
|
|
5
5
|
var sha2 = require('@noble/hashes/sha2');
|
|
6
6
|
var core = require('@naylence/core');
|
|
7
|
+
var yaml = require('yaml');
|
|
7
8
|
var asn1Schema = require('@peculiar/asn1-schema');
|
|
8
9
|
var asn1X509 = require('@peculiar/asn1-x509');
|
|
9
10
|
var sha2_js = require('@noble/hashes/sha2.js');
|
|
@@ -25,6 +26,7 @@ var sha256_js = require('@noble/hashes/sha256.js');
|
|
|
25
26
|
*/
|
|
26
27
|
const MODULES = [
|
|
27
28
|
"./security/auth/policy/advanced-authorization-policy-factory.js",
|
|
29
|
+
"./security/auth/policy/http-authorization-policy-source-factory.js",
|
|
28
30
|
"./security/cert/default-ca-service-factory.js",
|
|
29
31
|
"./security/cert/default-certificate-manager-factory.js",
|
|
30
32
|
"./security/cert/trust-store/browser-trust-store-provider-factory.js",
|
|
@@ -42,6 +44,7 @@ const MODULES = [
|
|
|
42
44
|
];
|
|
43
45
|
const MODULE_LOADERS = {
|
|
44
46
|
"./security/auth/policy/advanced-authorization-policy-factory.js": () => Promise.resolve().then(function () { return advancedAuthorizationPolicyFactory; }),
|
|
47
|
+
"./security/auth/policy/http-authorization-policy-source-factory.js": () => Promise.resolve().then(function () { return httpAuthorizationPolicySourceFactory; }),
|
|
45
48
|
"./security/cert/default-ca-service-factory.js": () => Promise.resolve().then(function () { return defaultCaServiceFactory; }),
|
|
46
49
|
"./security/cert/default-certificate-manager-factory.js": () => Promise.resolve().then(function () { return defaultCertificateManagerFactory; }),
|
|
47
50
|
"./security/cert/trust-store/browser-trust-store-provider-factory.js": () => Promise.resolve().then(function () { return browserTrustStoreProviderFactory; }),
|
|
@@ -58,7 +61,7 @@ const MODULE_LOADERS = {
|
|
|
58
61
|
"./welcome/advanced-welcome-service-factory.js": () => Promise.resolve().then(function () { return advancedWelcomeServiceFactory; }),
|
|
59
62
|
};
|
|
60
63
|
|
|
61
|
-
const logger$
|
|
64
|
+
const logger$i = runtime.getLogger("naylence.fame.security.encryption.encryption_manager_registry");
|
|
62
65
|
class EncryptionManagerFactoryRegistry {
|
|
63
66
|
constructor(autoDiscover = true) {
|
|
64
67
|
this.factories = [];
|
|
@@ -80,7 +83,7 @@ class EncryptionManagerFactoryRegistry {
|
|
|
80
83
|
let registeredCount = 0;
|
|
81
84
|
for (const [factoryName, info] of extensionInfos) {
|
|
82
85
|
if (factoryName === "CompositeEncryptionManager") {
|
|
83
|
-
logger$
|
|
86
|
+
logger$i.debug("skipping_composite_factory_to_avoid_circular_dependency", {
|
|
84
87
|
factory_name: factoryName,
|
|
85
88
|
});
|
|
86
89
|
continue;
|
|
@@ -90,7 +93,7 @@ class EncryptionManagerFactoryRegistry {
|
|
|
90
93
|
factory.ExtensionManager.getGlobalFactory(runtime.ENCRYPTION_MANAGER_FACTORY_BASE_TYPE, factoryName));
|
|
91
94
|
this.registerFactory(factoryInstance, { autoDiscovered: true });
|
|
92
95
|
registeredCount += 1;
|
|
93
|
-
logger$
|
|
96
|
+
logger$i.debug("auto_discovered_factory", {
|
|
94
97
|
factory_name: factoryName,
|
|
95
98
|
factory_class: factoryInstance.constructor.name,
|
|
96
99
|
algorithms: factoryInstance.getSupportedAlgorithms(),
|
|
@@ -99,21 +102,21 @@ class EncryptionManagerFactoryRegistry {
|
|
|
99
102
|
});
|
|
100
103
|
}
|
|
101
104
|
catch (error) {
|
|
102
|
-
logger$
|
|
105
|
+
logger$i.warning("failed_to_auto_register_factory", {
|
|
103
106
|
factory_name: factoryName,
|
|
104
107
|
error: error instanceof Error ? error.message : String(error),
|
|
105
108
|
});
|
|
106
109
|
}
|
|
107
110
|
}
|
|
108
111
|
this.autoDiscovered = true;
|
|
109
|
-
logger$
|
|
112
|
+
logger$i.debug("completed_auto_discovery", {
|
|
110
113
|
registered_factories: registeredCount,
|
|
111
114
|
total_discovered: extensionInfos.size,
|
|
112
115
|
skipped_composite: true,
|
|
113
116
|
});
|
|
114
117
|
}
|
|
115
118
|
catch (error) {
|
|
116
|
-
logger$
|
|
119
|
+
logger$i.warning("failed_auto_discovery_of_factories", {
|
|
117
120
|
error: error instanceof Error ? error.message : String(error),
|
|
118
121
|
});
|
|
119
122
|
}
|
|
@@ -131,7 +134,7 @@ class EncryptionManagerFactoryRegistry {
|
|
|
131
134
|
const existing = this.algorithmToFactory.get(algorithm);
|
|
132
135
|
if (!existing || factory.getPriority() > existing.getPriority()) {
|
|
133
136
|
this.algorithmToFactory.set(algorithm, factory);
|
|
134
|
-
logger$
|
|
137
|
+
logger$i.debug("registered_algorithm_mapping", {
|
|
135
138
|
algorithm,
|
|
136
139
|
factory: factory.constructor.name,
|
|
137
140
|
priority: factory.getPriority(),
|
|
@@ -143,7 +146,7 @@ class EncryptionManagerFactoryRegistry {
|
|
|
143
146
|
typeFactories.push(factory);
|
|
144
147
|
typeFactories.sort((a, b) => b.getPriority() - a.getPriority());
|
|
145
148
|
this.typeToFactories.set(encryptionType, typeFactories);
|
|
146
|
-
logger$
|
|
149
|
+
logger$i.debug("registered_encryption_manager_factory", {
|
|
147
150
|
factory: factory.constructor.name,
|
|
148
151
|
encryption_type: encryptionType,
|
|
149
152
|
algorithms: factory.getSupportedAlgorithms(),
|
|
@@ -159,14 +162,14 @@ class EncryptionManagerFactoryRegistry {
|
|
|
159
162
|
this.ensureAutoDiscovery();
|
|
160
163
|
for (const factory of this.factories) {
|
|
161
164
|
if (factory.supportsOptions(opts ?? undefined)) {
|
|
162
|
-
logger$
|
|
165
|
+
logger$i.debug("found_factory_for_options", {
|
|
163
166
|
factory: factory.constructor.name,
|
|
164
167
|
encryption_type: factory.getEncryptionType(),
|
|
165
168
|
});
|
|
166
169
|
return factory;
|
|
167
170
|
}
|
|
168
171
|
}
|
|
169
|
-
logger$
|
|
172
|
+
logger$i.debug("no_factory_found_for_options", { opts });
|
|
170
173
|
return undefined;
|
|
171
174
|
}
|
|
172
175
|
getFactoriesByType(encryptionType) {
|
|
@@ -291,10 +294,87 @@ var strictOverlaySecurityProfile = /*#__PURE__*/Object.freeze({
|
|
|
291
294
|
PROFILE_NAME_STRICT_OVERLAY: PROFILE_NAME_STRICT_OVERLAY
|
|
292
295
|
});
|
|
293
296
|
|
|
297
|
+
/**
|
|
298
|
+
* HTTP Policy Authorization Profile
|
|
299
|
+
*
|
|
300
|
+
* Provides the 'policy-http' authorization profile for loading policies over HTTP(S).
|
|
301
|
+
* This profile is similar to 'policy-localfile' from the runtime package but uses
|
|
302
|
+
* the HttpAuthorizationPolicySource instead of LocalFileAuthorizationPolicySource.
|
|
303
|
+
*/
|
|
304
|
+
// Environment variable names for HTTP policy source
|
|
305
|
+
const ENV_VAR_AUTH_POLICY_URL = "FAME_AUTH_POLICY_URL";
|
|
306
|
+
const ENV_VAR_AUTH_POLICY_TIMEOUT_MS = "FAME_AUTH_POLICY_TIMEOUT_MS";
|
|
307
|
+
const ENV_VAR_AUTH_POLICY_CACHE_TTL_MS = "FAME_AUTH_POLICY_CACHE_TTL_MS";
|
|
308
|
+
const ENV_VAR_AUTH_POLICY_TOKEN_URL = "FAME_AUTH_POLICY_TOKEN_URL";
|
|
309
|
+
const ENV_VAR_AUTH_POLICY_CLIENT_ID = "FAME_AUTH_POLICY_CLIENT_ID";
|
|
310
|
+
const ENV_VAR_AUTH_POLICY_CLIENT_SECRET = "FAME_AUTH_POLICY_CLIENT_SECRET";
|
|
311
|
+
const ENV_VAR_AUTH_POLICY_AUDIENCE = "FAME_AUTH_POLICY_AUDIENCE";
|
|
312
|
+
// Legacy environment variable for backwards compatibility
|
|
313
|
+
const ENV_VAR_AUTH_POLICY_BEARER_TOKEN = "FAME_AUTH_POLICY_BEARER_TOKEN";
|
|
314
|
+
// Profile name constant
|
|
315
|
+
const PROFILE_NAME_POLICY_HTTP = "policy-http";
|
|
316
|
+
// Re-use JWT verifier env vars from runtime
|
|
317
|
+
const ENV_VAR_JWKS_URL = "FAME_JWKS_URL";
|
|
318
|
+
const ENV_VAR_JWT_TRUSTED_ISSUER = "FAME_JWT_TRUSTED_ISSUER";
|
|
319
|
+
/**
|
|
320
|
+
* Default token verifier configuration using JWKS.
|
|
321
|
+
*/
|
|
322
|
+
const DEFAULT_VERIFIER_CONFIG = {
|
|
323
|
+
type: "JWKSJWTTokenVerifier",
|
|
324
|
+
jwks_url: factory.Expressions.env(ENV_VAR_JWKS_URL),
|
|
325
|
+
issuer: factory.Expressions.env(ENV_VAR_JWT_TRUSTED_ISSUER),
|
|
326
|
+
};
|
|
327
|
+
/**
|
|
328
|
+
* Creates OAuth2 token provider configuration for HTTP policy source.
|
|
329
|
+
*
|
|
330
|
+
* Uses environment variables for OAuth2 client credentials flow.
|
|
331
|
+
*/
|
|
332
|
+
function createOAuth2TokenProviderConfig() {
|
|
333
|
+
const tokenUrl = factory.Expressions.env(ENV_VAR_AUTH_POLICY_TOKEN_URL);
|
|
334
|
+
const clientId = factory.Expressions.env(ENV_VAR_AUTH_POLICY_CLIENT_ID);
|
|
335
|
+
const clientSecret = factory.Expressions.env(ENV_VAR_AUTH_POLICY_CLIENT_SECRET);
|
|
336
|
+
const audience = factory.Expressions.env(ENV_VAR_AUTH_POLICY_AUDIENCE);
|
|
337
|
+
return {
|
|
338
|
+
type: "OAuth2ClientCredentialsTokenProvider",
|
|
339
|
+
token_url: tokenUrl,
|
|
340
|
+
tokenUrl,
|
|
341
|
+
client_id: clientId,
|
|
342
|
+
clientId,
|
|
343
|
+
client_secret: clientSecret,
|
|
344
|
+
clientSecret,
|
|
345
|
+
scopes: ["policy.read"],
|
|
346
|
+
audience,
|
|
347
|
+
};
|
|
348
|
+
}
|
|
349
|
+
/**
|
|
350
|
+
* Default HTTP policy source configuration.
|
|
351
|
+
*
|
|
352
|
+
* Uses environment variables for URL, timeout, and OAuth2 client credentials.
|
|
353
|
+
*/
|
|
354
|
+
const DEFAULT_HTTP_POLICY_SOURCE = {
|
|
355
|
+
type: "HttpAuthorizationPolicySource",
|
|
356
|
+
url: factory.Expressions.env(ENV_VAR_AUTH_POLICY_URL),
|
|
357
|
+
timeout_ms: factory.Expressions.env(ENV_VAR_AUTH_POLICY_TIMEOUT_MS, "30000"),
|
|
358
|
+
cache_ttl_ms: factory.Expressions.env(ENV_VAR_AUTH_POLICY_CACHE_TTL_MS, "300000"),
|
|
359
|
+
// OAuth2 client credentials token provider
|
|
360
|
+
token_provider: createOAuth2TokenProviderConfig(),
|
|
361
|
+
};
|
|
362
|
+
const POLICY_HTTP_PROFILE = {
|
|
363
|
+
type: "PolicyAuthorizer",
|
|
364
|
+
verifier: DEFAULT_VERIFIER_CONFIG,
|
|
365
|
+
policy_source: DEFAULT_HTTP_POLICY_SOURCE,
|
|
366
|
+
};
|
|
367
|
+
// Register the policy-http profile
|
|
368
|
+
runtime.registerProfile(runtime.AUTHORIZER_FACTORY_BASE_TYPE, PROFILE_NAME_POLICY_HTTP, POLICY_HTTP_PROFILE, {
|
|
369
|
+
source: "advanced-security:policy-http-authorization-profile",
|
|
370
|
+
allowOverride: true,
|
|
371
|
+
});
|
|
372
|
+
|
|
294
373
|
const SECURITY_PREFIX = "./security/";
|
|
295
374
|
const SECURITY_MODULES = MODULES.filter((spec) => spec.startsWith(SECURITY_PREFIX));
|
|
296
375
|
const EXTRA_MODULES = MODULES.filter((spec) => !spec.startsWith(SECURITY_PREFIX));
|
|
297
376
|
const NODE_ONLY_MODULES = new Set([
|
|
377
|
+
"./security/auth/policy/http-authorization-policy-source-factory.js",
|
|
298
378
|
"./security/cert/default-ca-service-factory.js",
|
|
299
379
|
"./security/cert/trust-store/node-trust-store-provider-factory.js",
|
|
300
380
|
]);
|
|
@@ -575,12 +655,12 @@ async function registerAdvancedSecurityFactories(registrar = factory.Registry, o
|
|
|
575
655
|
}
|
|
576
656
|
|
|
577
657
|
// This file is auto-generated during build - do not edit manually
|
|
578
|
-
// Generated from package.json version: 0.4.
|
|
658
|
+
// Generated from package.json version: 0.4.7
|
|
579
659
|
/**
|
|
580
660
|
* The package version, injected at build time.
|
|
581
661
|
* @internal
|
|
582
662
|
*/
|
|
583
|
-
const VERSION = '0.4.
|
|
663
|
+
const VERSION = '0.4.7';
|
|
584
664
|
|
|
585
665
|
async function registerAdvancedSecurityPluginFactories(registrar = factory.Registry) {
|
|
586
666
|
await registerAdvancedSecurityFactories(registrar, { includeExtras: true });
|
|
@@ -3486,7 +3566,7 @@ function getModule() {
|
|
|
3486
3566
|
}
|
|
3487
3567
|
return modulePromise;
|
|
3488
3568
|
}
|
|
3489
|
-
function normalizeConfig$
|
|
3569
|
+
function normalizeConfig$6(config) {
|
|
3490
3570
|
if (!config) {
|
|
3491
3571
|
throw new Error("AdvancedAuthorizationPolicyFactory requires a configuration with a policyDefinition");
|
|
3492
3572
|
}
|
|
@@ -3515,7 +3595,7 @@ function normalizeConfig$5(config) {
|
|
|
3515
3595
|
/**
|
|
3516
3596
|
* Factory metadata for registration.
|
|
3517
3597
|
*/
|
|
3518
|
-
const FACTORY_META$
|
|
3598
|
+
const FACTORY_META$g = {
|
|
3519
3599
|
base: runtime.AUTHORIZATION_POLICY_FACTORY_BASE_TYPE,
|
|
3520
3600
|
key: "AdvancedAuthorizationPolicy",
|
|
3521
3601
|
};
|
|
@@ -3534,7 +3614,7 @@ class AdvancedAuthorizationPolicyFactory extends runtime.AuthorizationPolicyFact
|
|
|
3534
3614
|
* @returns The created authorization policy
|
|
3535
3615
|
*/
|
|
3536
3616
|
async create(config) {
|
|
3537
|
-
const normalized = normalizeConfig$
|
|
3617
|
+
const normalized = normalizeConfig$6(config);
|
|
3538
3618
|
const { AdvancedAuthorizationPolicy } = await getModule();
|
|
3539
3619
|
return new AdvancedAuthorizationPolicy({
|
|
3540
3620
|
policyDefinition: normalized.policyDefinition,
|
|
@@ -3547,10 +3627,493 @@ class AdvancedAuthorizationPolicyFactory extends runtime.AuthorizationPolicyFact
|
|
|
3547
3627
|
var advancedAuthorizationPolicyFactory = /*#__PURE__*/Object.freeze({
|
|
3548
3628
|
__proto__: null,
|
|
3549
3629
|
AdvancedAuthorizationPolicyFactory: AdvancedAuthorizationPolicyFactory,
|
|
3550
|
-
FACTORY_META: FACTORY_META$
|
|
3630
|
+
FACTORY_META: FACTORY_META$g,
|
|
3551
3631
|
default: AdvancedAuthorizationPolicyFactory
|
|
3552
3632
|
});
|
|
3553
3633
|
|
|
3634
|
+
/**
|
|
3635
|
+
* HTTP-based authorization policy source.
|
|
3636
|
+
*
|
|
3637
|
+
* Loads authorization policies from an HTTP endpoint supporting JSON or YAML.
|
|
3638
|
+
* Supports bearer authentication via TokenProvider and HTTP caching via ETag.
|
|
3639
|
+
*
|
|
3640
|
+
* This is a Node.js-only implementation.
|
|
3641
|
+
*
|
|
3642
|
+
* @packageDocumentation
|
|
3643
|
+
*/
|
|
3644
|
+
const logger$h = runtime.getLogger("naylence.fame.security.auth.policy.http_authorization_policy_source");
|
|
3645
|
+
function isPlainObject(value) {
|
|
3646
|
+
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
3647
|
+
}
|
|
3648
|
+
function parseJson(content) {
|
|
3649
|
+
const parsed = JSON.parse(content);
|
|
3650
|
+
if (!isPlainObject(parsed)) {
|
|
3651
|
+
throw new Error("Parsed JSON policy must be an object");
|
|
3652
|
+
}
|
|
3653
|
+
return parsed;
|
|
3654
|
+
}
|
|
3655
|
+
function parseYamlContent(content) {
|
|
3656
|
+
const parsed = yaml.parse(content ?? "");
|
|
3657
|
+
if (parsed == null) {
|
|
3658
|
+
return {};
|
|
3659
|
+
}
|
|
3660
|
+
if (!isPlainObject(parsed)) {
|
|
3661
|
+
throw new Error("Parsed YAML policy must be an object");
|
|
3662
|
+
}
|
|
3663
|
+
return parsed;
|
|
3664
|
+
}
|
|
3665
|
+
/**
|
|
3666
|
+
* Detect whether content is JSON or YAML based on Content-Type header.
|
|
3667
|
+
* Falls back to sniffing the content if Content-Type is not definitive.
|
|
3668
|
+
*/
|
|
3669
|
+
function detectFormat(contentType, content) {
|
|
3670
|
+
if (contentType) {
|
|
3671
|
+
const lower = contentType.toLowerCase();
|
|
3672
|
+
if (lower.includes("application/json") ||
|
|
3673
|
+
lower.includes("text/json")) {
|
|
3674
|
+
return "json";
|
|
3675
|
+
}
|
|
3676
|
+
if (lower.includes("application/yaml") ||
|
|
3677
|
+
lower.includes("application/x-yaml") ||
|
|
3678
|
+
lower.includes("text/yaml") ||
|
|
3679
|
+
lower.includes("text/x-yaml")) {
|
|
3680
|
+
return "yaml";
|
|
3681
|
+
}
|
|
3682
|
+
}
|
|
3683
|
+
// Sniff by first non-whitespace character
|
|
3684
|
+
const trimmed = content.trimStart();
|
|
3685
|
+
if (trimmed.startsWith("{") || trimmed.startsWith("[")) {
|
|
3686
|
+
return "json";
|
|
3687
|
+
}
|
|
3688
|
+
// Default to YAML
|
|
3689
|
+
return "yaml";
|
|
3690
|
+
}
|
|
3691
|
+
/**
|
|
3692
|
+
* Parse Cache-Control header to extract max-age value.
|
|
3693
|
+
*/
|
|
3694
|
+
function parseMaxAge(cacheControl) {
|
|
3695
|
+
if (!cacheControl) {
|
|
3696
|
+
return undefined;
|
|
3697
|
+
}
|
|
3698
|
+
const match = cacheControl.match(/max-age\s*=\s*(\d+)/i);
|
|
3699
|
+
if (match && match[1]) {
|
|
3700
|
+
const seconds = parseInt(match[1], 10);
|
|
3701
|
+
if (Number.isFinite(seconds) && seconds >= 0) {
|
|
3702
|
+
return seconds;
|
|
3703
|
+
}
|
|
3704
|
+
}
|
|
3705
|
+
return undefined;
|
|
3706
|
+
}
|
|
3707
|
+
/**
|
|
3708
|
+
* An authorization policy source that loads policy definitions from an HTTP endpoint.
|
|
3709
|
+
*
|
|
3710
|
+
* Supports JSON and YAML formats, bearer authentication via TokenProvider,
|
|
3711
|
+
* and HTTP caching via ETag and Cache-Control headers.
|
|
3712
|
+
*
|
|
3713
|
+
* This is a Node.js-only implementation that uses fetch.
|
|
3714
|
+
*/
|
|
3715
|
+
class HttpAuthorizationPolicySource {
|
|
3716
|
+
constructor(options) {
|
|
3717
|
+
this.cachedState = null;
|
|
3718
|
+
this.inflightFetch = null;
|
|
3719
|
+
if (!options.url || typeof options.url !== "string") {
|
|
3720
|
+
throw new Error("HttpAuthorizationPolicySource requires a valid URL");
|
|
3721
|
+
}
|
|
3722
|
+
this.url = options.url;
|
|
3723
|
+
this.method = options.method ?? "GET";
|
|
3724
|
+
this.timeoutMs = options.timeoutMs ?? 30000;
|
|
3725
|
+
this.headers = { ...options.headers };
|
|
3726
|
+
this.tokenProvider = options.tokenProvider;
|
|
3727
|
+
this.bearerPrefix = options.bearerPrefix ?? "Bearer ";
|
|
3728
|
+
this.policyFactoryConfig = options.policyFactory;
|
|
3729
|
+
this.cacheTtlMs = options.cacheTtlMs ?? 300000; // 5 minutes default
|
|
3730
|
+
}
|
|
3731
|
+
/**
|
|
3732
|
+
* Loads the authorization policy from the configured HTTP endpoint.
|
|
3733
|
+
*
|
|
3734
|
+
* Returns a cached policy if still fresh (based on TTL or cache headers).
|
|
3735
|
+
* Multiple concurrent calls are de-duplicated (single-flight pattern).
|
|
3736
|
+
*
|
|
3737
|
+
* @returns The loaded authorization policy
|
|
3738
|
+
*/
|
|
3739
|
+
async loadPolicy() {
|
|
3740
|
+
// Return cached policy if still fresh
|
|
3741
|
+
if (this.cachedState && this.isCacheFresh()) {
|
|
3742
|
+
logger$h.debug("returning_cached_policy", {
|
|
3743
|
+
url: this.url,
|
|
3744
|
+
fetchedAt: this.cachedState.metadata.fetchedAt,
|
|
3745
|
+
expiresAt: this.cachedState.metadata.expiresAt,
|
|
3746
|
+
});
|
|
3747
|
+
return this.cachedState.policy;
|
|
3748
|
+
}
|
|
3749
|
+
// De-duplicate concurrent requests
|
|
3750
|
+
if (this.inflightFetch) {
|
|
3751
|
+
return this.inflightFetch;
|
|
3752
|
+
}
|
|
3753
|
+
this.inflightFetch = this.fetchPolicy(false);
|
|
3754
|
+
try {
|
|
3755
|
+
return await this.inflightFetch;
|
|
3756
|
+
}
|
|
3757
|
+
finally {
|
|
3758
|
+
this.inflightFetch = null;
|
|
3759
|
+
}
|
|
3760
|
+
}
|
|
3761
|
+
/**
|
|
3762
|
+
* Forces a reload of the policy from the HTTP endpoint.
|
|
3763
|
+
*
|
|
3764
|
+
* Bypasses cache freshness checks and always fetches from the server.
|
|
3765
|
+
* If the fetch fails, the existing cached policy is preserved and the error is thrown.
|
|
3766
|
+
*
|
|
3767
|
+
* @returns The reloaded authorization policy
|
|
3768
|
+
*/
|
|
3769
|
+
async reloadPolicy() {
|
|
3770
|
+
// Clear inflight to force a new request
|
|
3771
|
+
this.inflightFetch = null;
|
|
3772
|
+
return this.fetchPolicy(true);
|
|
3773
|
+
}
|
|
3774
|
+
/**
|
|
3775
|
+
* Clears the cached policy, forcing a fresh fetch on the next loadPolicy() call.
|
|
3776
|
+
*/
|
|
3777
|
+
clearCache() {
|
|
3778
|
+
this.cachedState = null;
|
|
3779
|
+
this.inflightFetch = null;
|
|
3780
|
+
}
|
|
3781
|
+
/**
|
|
3782
|
+
* Returns metadata about the last successful fetch.
|
|
3783
|
+
*
|
|
3784
|
+
* Useful for verification, monitoring, or debugging.
|
|
3785
|
+
*/
|
|
3786
|
+
getMetadata() {
|
|
3787
|
+
return this.cachedState?.metadata;
|
|
3788
|
+
}
|
|
3789
|
+
/**
|
|
3790
|
+
* Returns the raw policy definition from the last successful fetch.
|
|
3791
|
+
*
|
|
3792
|
+
* Useful for verification or reprocessing.
|
|
3793
|
+
*/
|
|
3794
|
+
getRawDefinition() {
|
|
3795
|
+
return this.cachedState?.rawDefinition;
|
|
3796
|
+
}
|
|
3797
|
+
isCacheFresh() {
|
|
3798
|
+
if (!this.cachedState) {
|
|
3799
|
+
return false;
|
|
3800
|
+
}
|
|
3801
|
+
const now = Date.now();
|
|
3802
|
+
const { expiresAt } = this.cachedState.metadata;
|
|
3803
|
+
if (expiresAt !== undefined) {
|
|
3804
|
+
return now < expiresAt;
|
|
3805
|
+
}
|
|
3806
|
+
// No expiration info, check against default TTL
|
|
3807
|
+
const fetchedAt = this.cachedState.metadata.fetchedAt;
|
|
3808
|
+
return now < fetchedAt + this.cacheTtlMs;
|
|
3809
|
+
}
|
|
3810
|
+
async fetchPolicy(forceRefresh) {
|
|
3811
|
+
logger$h.debug("fetching_policy", {
|
|
3812
|
+
url: this.url,
|
|
3813
|
+
method: this.method,
|
|
3814
|
+
forceRefresh,
|
|
3815
|
+
});
|
|
3816
|
+
const requestHeaders = {
|
|
3817
|
+
Accept: "application/json, application/yaml, text/yaml, */*",
|
|
3818
|
+
...this.headers,
|
|
3819
|
+
};
|
|
3820
|
+
// Add bearer token if token provider is configured
|
|
3821
|
+
if (this.tokenProvider) {
|
|
3822
|
+
try {
|
|
3823
|
+
const token = await this.tokenProvider.getToken();
|
|
3824
|
+
if (token && token.value) {
|
|
3825
|
+
requestHeaders["Authorization"] = `${this.bearerPrefix}${token.value}`;
|
|
3826
|
+
logger$h.debug("added_bearer_token", { url: this.url });
|
|
3827
|
+
}
|
|
3828
|
+
}
|
|
3829
|
+
catch (error) {
|
|
3830
|
+
logger$h.warning("token_provider_failed", {
|
|
3831
|
+
url: this.url,
|
|
3832
|
+
error: error instanceof Error ? error.message : String(error),
|
|
3833
|
+
});
|
|
3834
|
+
// Continue without token - let the server decide if auth is required
|
|
3835
|
+
}
|
|
3836
|
+
}
|
|
3837
|
+
// Add If-None-Match header for conditional request if we have a cached ETag
|
|
3838
|
+
// and this is not a forced refresh
|
|
3839
|
+
if (!forceRefresh && this.cachedState?.metadata.etag) {
|
|
3840
|
+
requestHeaders["If-None-Match"] = this.cachedState.metadata.etag;
|
|
3841
|
+
}
|
|
3842
|
+
const controller = new AbortController();
|
|
3843
|
+
const timeoutId = setTimeout(() => controller.abort(), this.timeoutMs);
|
|
3844
|
+
try {
|
|
3845
|
+
const response = await fetch(this.url, {
|
|
3846
|
+
method: this.method,
|
|
3847
|
+
headers: requestHeaders,
|
|
3848
|
+
signal: controller.signal,
|
|
3849
|
+
});
|
|
3850
|
+
clearTimeout(timeoutId);
|
|
3851
|
+
// Handle 304 Not Modified - return cached policy
|
|
3852
|
+
if (response.status === 304 && this.cachedState) {
|
|
3853
|
+
logger$h.debug("policy_not_modified", {
|
|
3854
|
+
url: this.url,
|
|
3855
|
+
etag: this.cachedState.metadata.etag,
|
|
3856
|
+
});
|
|
3857
|
+
// Update freshness timestamps
|
|
3858
|
+
const now = Date.now();
|
|
3859
|
+
const cacheControl = response.headers.get("Cache-Control");
|
|
3860
|
+
const maxAgeSeconds = parseMaxAge(cacheControl);
|
|
3861
|
+
const expiresAt = maxAgeSeconds !== undefined
|
|
3862
|
+
? now + maxAgeSeconds * 1000
|
|
3863
|
+
: now + this.cacheTtlMs;
|
|
3864
|
+
this.cachedState = {
|
|
3865
|
+
...this.cachedState,
|
|
3866
|
+
metadata: {
|
|
3867
|
+
...this.cachedState.metadata,
|
|
3868
|
+
fetchedAt: now,
|
|
3869
|
+
maxAgeSeconds,
|
|
3870
|
+
expiresAt,
|
|
3871
|
+
},
|
|
3872
|
+
};
|
|
3873
|
+
return this.cachedState.policy;
|
|
3874
|
+
}
|
|
3875
|
+
if (!response.ok) {
|
|
3876
|
+
const errorMessage = `HTTP ${response.status}: ${response.statusText}`;
|
|
3877
|
+
logger$h.error("policy_fetch_failed", {
|
|
3878
|
+
url: this.url,
|
|
3879
|
+
status: response.status,
|
|
3880
|
+
statusText: response.statusText,
|
|
3881
|
+
});
|
|
3882
|
+
// If we have a cached policy, preserve it and throw
|
|
3883
|
+
if (this.cachedState) {
|
|
3884
|
+
throw new Error(`Failed to fetch policy from ${this.url}: ${errorMessage}. ` +
|
|
3885
|
+
"Using last known good policy.");
|
|
3886
|
+
}
|
|
3887
|
+
throw new Error(`Failed to fetch policy from ${this.url}: ${errorMessage}`);
|
|
3888
|
+
}
|
|
3889
|
+
// Parse the response
|
|
3890
|
+
const contentType = response.headers.get("Content-Type");
|
|
3891
|
+
const content = await response.text();
|
|
3892
|
+
const format = detectFormat(contentType, content);
|
|
3893
|
+
let policyDefinition;
|
|
3894
|
+
try {
|
|
3895
|
+
if (format === "json") {
|
|
3896
|
+
policyDefinition = parseJson(content);
|
|
3897
|
+
}
|
|
3898
|
+
else {
|
|
3899
|
+
policyDefinition = parseYamlContent(content);
|
|
3900
|
+
}
|
|
3901
|
+
}
|
|
3902
|
+
catch (parseError) {
|
|
3903
|
+
const message = parseError instanceof Error
|
|
3904
|
+
? parseError.message
|
|
3905
|
+
: String(parseError);
|
|
3906
|
+
logger$h.error("policy_parse_failed", {
|
|
3907
|
+
url: this.url,
|
|
3908
|
+
format,
|
|
3909
|
+
error: message,
|
|
3910
|
+
});
|
|
3911
|
+
// Preserve cached policy on parse failure
|
|
3912
|
+
if (this.cachedState) {
|
|
3913
|
+
throw new Error(`Failed to parse policy from ${this.url}: ${message}. ` +
|
|
3914
|
+
"Using last known good policy.");
|
|
3915
|
+
}
|
|
3916
|
+
throw new Error(`Failed to parse policy from ${this.url}: ${message}`);
|
|
3917
|
+
}
|
|
3918
|
+
logger$h.debug("parsed_policy_definition", {
|
|
3919
|
+
url: this.url,
|
|
3920
|
+
format,
|
|
3921
|
+
hasType: "type" in policyDefinition,
|
|
3922
|
+
});
|
|
3923
|
+
// Build the policy using the factory
|
|
3924
|
+
const policy = await this.buildPolicy(policyDefinition);
|
|
3925
|
+
// Update cache
|
|
3926
|
+
const now = Date.now();
|
|
3927
|
+
const etag = response.headers.get("ETag") ?? undefined;
|
|
3928
|
+
const cacheControl = response.headers.get("Cache-Control");
|
|
3929
|
+
const maxAgeSeconds = parseMaxAge(cacheControl);
|
|
3930
|
+
const expiresAt = maxAgeSeconds !== undefined
|
|
3931
|
+
? now + maxAgeSeconds * 1000
|
|
3932
|
+
: now + this.cacheTtlMs;
|
|
3933
|
+
this.cachedState = {
|
|
3934
|
+
policy,
|
|
3935
|
+
rawDefinition: policyDefinition,
|
|
3936
|
+
metadata: {
|
|
3937
|
+
url: this.url,
|
|
3938
|
+
status: response.status,
|
|
3939
|
+
etag,
|
|
3940
|
+
fetchedAt: now,
|
|
3941
|
+
maxAgeSeconds,
|
|
3942
|
+
expiresAt,
|
|
3943
|
+
},
|
|
3944
|
+
};
|
|
3945
|
+
logger$h.info("loaded_policy_from_http", {
|
|
3946
|
+
url: this.url,
|
|
3947
|
+
status: response.status,
|
|
3948
|
+
format,
|
|
3949
|
+
etag,
|
|
3950
|
+
maxAgeSeconds,
|
|
3951
|
+
});
|
|
3952
|
+
return policy;
|
|
3953
|
+
}
|
|
3954
|
+
catch (error) {
|
|
3955
|
+
clearTimeout(timeoutId);
|
|
3956
|
+
if (error instanceof Error && error.name === "AbortError") {
|
|
3957
|
+
const timeoutError = new Error(`Request to ${this.url} timed out after ${this.timeoutMs}ms`);
|
|
3958
|
+
logger$h.error("policy_fetch_timeout", {
|
|
3959
|
+
url: this.url,
|
|
3960
|
+
timeoutMs: this.timeoutMs,
|
|
3961
|
+
});
|
|
3962
|
+
// Preserve cached policy on timeout
|
|
3963
|
+
if (this.cachedState) {
|
|
3964
|
+
throw timeoutError;
|
|
3965
|
+
}
|
|
3966
|
+
throw timeoutError;
|
|
3967
|
+
}
|
|
3968
|
+
throw error;
|
|
3969
|
+
}
|
|
3970
|
+
}
|
|
3971
|
+
async buildPolicy(policyDefinition) {
|
|
3972
|
+
// Determine the factory configuration to use
|
|
3973
|
+
const factoryConfig = this.policyFactoryConfig ?? policyDefinition;
|
|
3974
|
+
// Ensure we have a type field for the factory
|
|
3975
|
+
if (!("type" in factoryConfig) || typeof factoryConfig.type !== "string") {
|
|
3976
|
+
logger$h.warning("policy_type_missing_defaulting_to_basic", {
|
|
3977
|
+
url: this.url,
|
|
3978
|
+
});
|
|
3979
|
+
factoryConfig.type = "BasicAuthorizationPolicy";
|
|
3980
|
+
}
|
|
3981
|
+
// Build the factory config with the policy definition
|
|
3982
|
+
// The response content IS the policy definition, so we extract the type
|
|
3983
|
+
// and wrap the remaining content as the policyDefinition
|
|
3984
|
+
const { type: definitionType, ...restOfDefinition } = policyDefinition;
|
|
3985
|
+
const resolvedType = typeof definitionType === "string" && definitionType.trim().length > 0
|
|
3986
|
+
? definitionType
|
|
3987
|
+
: factoryConfig.type;
|
|
3988
|
+
const mergedConfig = this.policyFactoryConfig != null
|
|
3989
|
+
? { ...this.policyFactoryConfig, policyDefinition }
|
|
3990
|
+
: { type: resolvedType, policyDefinition: restOfDefinition };
|
|
3991
|
+
const policy = await runtime.AuthorizationPolicyFactory.createAuthorizationPolicy(mergedConfig);
|
|
3992
|
+
if (!policy) {
|
|
3993
|
+
throw new Error(`Failed to create authorization policy from ${this.url}`);
|
|
3994
|
+
}
|
|
3995
|
+
return policy;
|
|
3996
|
+
}
|
|
3997
|
+
}
|
|
3998
|
+
|
|
3999
|
+
var httpAuthorizationPolicySource = /*#__PURE__*/Object.freeze({
|
|
4000
|
+
__proto__: null,
|
|
4001
|
+
HttpAuthorizationPolicySource: HttpAuthorizationPolicySource
|
|
4002
|
+
});
|
|
4003
|
+
|
|
4004
|
+
/**
|
|
4005
|
+
* Factory for creating HttpAuthorizationPolicySource instances.
|
|
4006
|
+
*
|
|
4007
|
+
* @packageDocumentation
|
|
4008
|
+
*/
|
|
4009
|
+
let httpModulePromise = null;
|
|
4010
|
+
async function getHttpModule() {
|
|
4011
|
+
if (!httpModulePromise) {
|
|
4012
|
+
httpModulePromise = Promise.resolve().then(function () { return httpAuthorizationPolicySource; });
|
|
4013
|
+
}
|
|
4014
|
+
return httpModulePromise;
|
|
4015
|
+
}
|
|
4016
|
+
function normalizeConfig$5(config) {
|
|
4017
|
+
if (!config) {
|
|
4018
|
+
throw new Error("HttpAuthorizationPolicySourceFactory requires a configuration with a url");
|
|
4019
|
+
}
|
|
4020
|
+
const candidate = config;
|
|
4021
|
+
const url = candidate.url;
|
|
4022
|
+
if (typeof url !== "string" || url.trim().length === 0) {
|
|
4023
|
+
throw new Error("HttpAuthorizationPolicySourceConfig requires a non-empty url");
|
|
4024
|
+
}
|
|
4025
|
+
// Support both camelCase and snake_case
|
|
4026
|
+
const method = candidate.method ?? "GET";
|
|
4027
|
+
if (!["GET", "POST", "PUT"].includes(method)) {
|
|
4028
|
+
throw new Error(`Invalid method "${String(method)}". Must be "GET", "POST", or "PUT"`);
|
|
4029
|
+
}
|
|
4030
|
+
const timeoutMs = candidate.timeout_ms ??
|
|
4031
|
+
candidate.timeoutMs ??
|
|
4032
|
+
30000;
|
|
4033
|
+
if (typeof timeoutMs !== "number" || !Number.isFinite(timeoutMs) || timeoutMs <= 0) {
|
|
4034
|
+
throw new Error("timeout_ms must be a positive number");
|
|
4035
|
+
}
|
|
4036
|
+
const headers = candidate.headers;
|
|
4037
|
+
if (headers !== undefined && typeof headers !== "object") {
|
|
4038
|
+
throw new Error("headers must be an object");
|
|
4039
|
+
}
|
|
4040
|
+
const tokenProviderConfig = candidate.token_provider ??
|
|
4041
|
+
candidate.tokenProvider;
|
|
4042
|
+
const bearerPrefix = candidate.bearer_prefix ??
|
|
4043
|
+
candidate.bearerPrefix ??
|
|
4044
|
+
"Bearer ";
|
|
4045
|
+
const policyFactory = candidate.policy_factory ??
|
|
4046
|
+
candidate.policyFactory;
|
|
4047
|
+
const cacheTtlMs = candidate.cache_ttl_ms ??
|
|
4048
|
+
candidate.cacheTtlMs ??
|
|
4049
|
+
300000;
|
|
4050
|
+
if (typeof cacheTtlMs !== "number" || !Number.isFinite(cacheTtlMs) || cacheTtlMs < 0) {
|
|
4051
|
+
throw new Error("cache_ttl_ms must be a non-negative number");
|
|
4052
|
+
}
|
|
4053
|
+
return {
|
|
4054
|
+
url: url.trim(),
|
|
4055
|
+
method,
|
|
4056
|
+
timeoutMs,
|
|
4057
|
+
headers,
|
|
4058
|
+
tokenProviderConfig,
|
|
4059
|
+
bearerPrefix,
|
|
4060
|
+
policyFactory,
|
|
4061
|
+
cacheTtlMs,
|
|
4062
|
+
};
|
|
4063
|
+
}
|
|
4064
|
+
/**
|
|
4065
|
+
* Factory metadata for registration.
|
|
4066
|
+
*/
|
|
4067
|
+
const FACTORY_META$f = {
|
|
4068
|
+
base: runtime.AUTHORIZATION_POLICY_SOURCE_FACTORY_BASE_TYPE,
|
|
4069
|
+
key: "HttpAuthorizationPolicySource",
|
|
4070
|
+
};
|
|
4071
|
+
/**
|
|
4072
|
+
* Factory for creating HttpAuthorizationPolicySource instances.
|
|
4073
|
+
*
|
|
4074
|
+
* This factory uses lazy loading to avoid pulling in Node.js-specific
|
|
4075
|
+
* code (fetch operations) in browser environments where it may not work.
|
|
4076
|
+
*/
|
|
4077
|
+
class HttpAuthorizationPolicySourceFactory extends runtime.AuthorizationPolicySourceFactory {
|
|
4078
|
+
constructor() {
|
|
4079
|
+
super(...arguments);
|
|
4080
|
+
this.type = "HttpAuthorizationPolicySource";
|
|
4081
|
+
}
|
|
4082
|
+
/**
|
|
4083
|
+
* Creates an HttpAuthorizationPolicySource from the given configuration.
|
|
4084
|
+
*
|
|
4085
|
+
* @param config - Configuration specifying the policy URL and options
|
|
4086
|
+
* @returns The created policy source
|
|
4087
|
+
*/
|
|
4088
|
+
async create(config) {
|
|
4089
|
+
const normalized = normalizeConfig$5(config);
|
|
4090
|
+
// Create token provider if configured
|
|
4091
|
+
let tokenProvider;
|
|
4092
|
+
if (normalized.tokenProviderConfig) {
|
|
4093
|
+
tokenProvider = await runtime.TokenProviderFactory.createTokenProvider(normalized.tokenProviderConfig);
|
|
4094
|
+
}
|
|
4095
|
+
const { HttpAuthorizationPolicySource } = await getHttpModule();
|
|
4096
|
+
const options = {
|
|
4097
|
+
url: normalized.url,
|
|
4098
|
+
method: normalized.method,
|
|
4099
|
+
timeoutMs: normalized.timeoutMs,
|
|
4100
|
+
headers: normalized.headers,
|
|
4101
|
+
tokenProvider,
|
|
4102
|
+
bearerPrefix: normalized.bearerPrefix,
|
|
4103
|
+
policyFactory: normalized.policyFactory,
|
|
4104
|
+
cacheTtlMs: normalized.cacheTtlMs,
|
|
4105
|
+
};
|
|
4106
|
+
return new HttpAuthorizationPolicySource(options);
|
|
4107
|
+
}
|
|
4108
|
+
}
|
|
4109
|
+
|
|
4110
|
+
var httpAuthorizationPolicySourceFactory = /*#__PURE__*/Object.freeze({
|
|
4111
|
+
__proto__: null,
|
|
4112
|
+
FACTORY_META: FACTORY_META$f,
|
|
4113
|
+
HttpAuthorizationPolicySourceFactory: HttpAuthorizationPolicySourceFactory,
|
|
4114
|
+
default: HttpAuthorizationPolicySourceFactory
|
|
4115
|
+
});
|
|
4116
|
+
|
|
3554
4117
|
/**
|
|
3555
4118
|
* Advanced authorization policy module exports.
|
|
3556
4119
|
*
|
|
@@ -3559,7 +4122,7 @@ var advancedAuthorizationPolicyFactory = /*#__PURE__*/Object.freeze({
|
|
|
3559
4122
|
*
|
|
3560
4123
|
* @packageDocumentation
|
|
3561
4124
|
*/
|
|
3562
|
-
//
|
|
4125
|
+
// Expression authorization policy
|
|
3563
4126
|
|
|
3564
4127
|
/**
|
|
3565
4128
|
* Advanced security authentication/authorization module exports.
|
|
@@ -13184,7 +13747,7 @@ if (isNode && proc && proc.env) {
|
|
|
13184
13747
|
}
|
|
13185
13748
|
}
|
|
13186
13749
|
|
|
13187
|
-
exports.ADVANCED_AUTHORIZATION_POLICY_FACTORY_META = FACTORY_META$
|
|
13750
|
+
exports.ADVANCED_AUTHORIZATION_POLICY_FACTORY_META = FACTORY_META$g;
|
|
13188
13751
|
exports.ADVANCED_EDDSA_ENVELOPE_SIGNER_FACTORY_META = FACTORY_META$a;
|
|
13189
13752
|
exports.ADVANCED_EDDSA_ENVELOPE_VERIFIER_FACTORY_META = FACTORY_META$9;
|
|
13190
13753
|
exports.ADVANCED_WELCOME_FACTORY_META = FACTORY_META$5;
|
|
@@ -13202,9 +13765,7 @@ exports.AdvancedEdDSAEnvelopeVerifierFactory = AdvancedEdDSAEnvelopeVerifierFact
|
|
|
13202
13765
|
exports.AdvancedWelcomeService = AdvancedWelcomeService;
|
|
13203
13766
|
exports.AdvancedWelcomeServiceFactory = AdvancedWelcomeServiceFactory;
|
|
13204
13767
|
exports.BROWSER_TRUST_STORE_PROVIDER_FACTORY_META = FACTORY_META$2;
|
|
13205
|
-
exports.BUILTIN_FUNCTIONS = BUILTIN_FUNCTIONS;
|
|
13206
13768
|
exports.BrowserTrustStoreProviderFactory = BrowserTrustStoreProviderFactory;
|
|
13207
|
-
exports.BuiltinError = BuiltinError;
|
|
13208
13769
|
exports.CAService = CAService;
|
|
13209
13770
|
exports.CAServiceClient = CAServiceClient;
|
|
13210
13771
|
exports.CAServiceFactory = CAServiceFactory;
|
|
@@ -13214,7 +13775,6 @@ exports.CertificateRequestError = CertificateRequestError;
|
|
|
13214
13775
|
exports.CompositeEncryptionManager = CompositeEncryptionManager;
|
|
13215
13776
|
exports.CompositeEncryptionManagerFactory = CompositeEncryptionManagerFactory;
|
|
13216
13777
|
exports.DEFAULT_CERTIFICATE_MANAGER_FACTORY_META = FACTORY_META$4;
|
|
13217
|
-
exports.DEFAULT_EXPRESSION_LIMITS = DEFAULT_EXPRESSION_LIMITS;
|
|
13218
13778
|
exports.DEFAULT_SECURE_CHANNEL_MANAGER_FACTORY_META = FACTORY_META$c;
|
|
13219
13779
|
exports.DEFAULT_STICKINESS_SECURITY_LEVEL = DEFAULT_STICKINESS_SECURITY_LEVEL;
|
|
13220
13780
|
exports.DefaultCAService = DefaultCAService;
|
|
@@ -13234,63 +13794,47 @@ exports.ENV_FAME_SIGNING_CERT_PEM = ENV_FAME_SIGNING_CERT_PEM;
|
|
|
13234
13794
|
exports.ENV_FAME_SIGNING_KEY_FILE = ENV_FAME_SIGNING_KEY_FILE;
|
|
13235
13795
|
exports.ENV_FAME_SIGNING_KEY_PEM = ENV_FAME_SIGNING_KEY_PEM;
|
|
13236
13796
|
exports.ENV_TRUST_STORE_PROVIDER_FACTORY_META = FACTORY_META$3;
|
|
13797
|
+
exports.ENV_VAR_AUTH_POLICY_BEARER_TOKEN = ENV_VAR_AUTH_POLICY_BEARER_TOKEN;
|
|
13798
|
+
exports.ENV_VAR_AUTH_POLICY_CACHE_TTL_MS = ENV_VAR_AUTH_POLICY_CACHE_TTL_MS;
|
|
13799
|
+
exports.ENV_VAR_AUTH_POLICY_TIMEOUT_MS = ENV_VAR_AUTH_POLICY_TIMEOUT_MS;
|
|
13800
|
+
exports.ENV_VAR_AUTH_POLICY_URL = ENV_VAR_AUTH_POLICY_URL;
|
|
13237
13801
|
exports.ENV_VAR_FAME_CA_SERVICE_URL = ENV_VAR_FAME_CA_SERVICE_URL;
|
|
13238
13802
|
exports.EdDSAEnvelopeVerifier = EdDSAEnvelopeVerifier;
|
|
13239
13803
|
exports.EnvTrustStoreProviderFactory = EnvTrustStoreProviderFactory;
|
|
13240
|
-
exports.EvaluationError = EvaluationError;
|
|
13241
|
-
exports.Evaluator = Evaluator;
|
|
13242
|
-
exports.ExpressionError = ExpressionError;
|
|
13243
13804
|
exports.GRANT_PURPOSE_CA_SIGN = GRANT_PURPOSE_CA_SIGN;
|
|
13805
|
+
exports.HTTP_AUTHORIZATION_POLICY_SOURCE_FACTORY_META = FACTORY_META$f;
|
|
13806
|
+
exports.HttpAuthorizationPolicySource = HttpAuthorizationPolicySource;
|
|
13807
|
+
exports.HttpAuthorizationPolicySourceFactory = HttpAuthorizationPolicySourceFactory;
|
|
13244
13808
|
exports.LOGICALS_OID = LOGICALS_OID;
|
|
13245
|
-
exports.LimitExceededError = LimitExceededError;
|
|
13246
13809
|
exports.NODE_ID_OID = NODE_ID_OID;
|
|
13247
13810
|
exports.NoAFTSigner = NoAFTSigner;
|
|
13248
13811
|
exports.NullTrustStoreProvider = NullTrustStoreProvider;
|
|
13812
|
+
exports.PROFILE_NAME_POLICY_HTTP = PROFILE_NAME_POLICY_HTTP;
|
|
13249
13813
|
exports.PROFILE_NAME_STRICT_OVERLAY = PROFILE_NAME_STRICT_OVERLAY;
|
|
13250
|
-
exports.ParseError = ParseError;
|
|
13251
|
-
exports.Parser = Parser;
|
|
13252
13814
|
exports.SID_OID = SID_OID;
|
|
13253
13815
|
exports.SidOnlyAFTVerifier = SidOnlyAFTVerifier;
|
|
13254
13816
|
exports.SignedAFTSigner = SignedAFTSigner;
|
|
13255
13817
|
exports.SignedOptionalAFTVerifier = SignedOptionalAFTVerifier;
|
|
13256
13818
|
exports.StrictAFTVerifier = StrictAFTVerifier;
|
|
13257
13819
|
exports.TRUST_STORE_PROVIDER_FACTORY_BASE_TYPE = TRUST_STORE_PROVIDER_FACTORY_BASE_TYPE;
|
|
13258
|
-
exports.Tokenizer = Tokenizer;
|
|
13259
|
-
exports.TokenizerError = TokenizerError;
|
|
13260
13820
|
exports.TrustStoreProviderFactory = TrustStoreProviderFactory;
|
|
13261
|
-
exports.TypeError = TypeError;
|
|
13262
13821
|
exports.UnsignedAFTSigner = UnsignedAFTSigner;
|
|
13263
13822
|
exports.VERSION = VERSION;
|
|
13264
13823
|
exports.X5CKeyManager = X5CKeyManager;
|
|
13265
13824
|
exports.X5CKeyManagerFactory = X5CKeyManagerFactory;
|
|
13266
13825
|
exports.X5C_KEY_MANAGER_FACTORY_META = FACTORY_META$8;
|
|
13267
13826
|
exports.__advancedSecurityPluginLoader = __advancedSecurityPluginLoader;
|
|
13268
|
-
exports.astToString = astToString;
|
|
13269
13827
|
exports.base64UrlDecode = base64UrlDecode;
|
|
13270
13828
|
exports.base64UrlEncode = base64UrlEncode;
|
|
13271
|
-
exports.calculateAstDepth = calculateAstDepth;
|
|
13272
|
-
exports.callBuiltin = callBuiltin;
|
|
13273
13829
|
exports.channelEncryption = index;
|
|
13274
|
-
exports.checkArrayLength = checkArrayLength;
|
|
13275
|
-
exports.checkAstDepth = checkAstDepth;
|
|
13276
|
-
exports.checkAstNodeCount = checkAstNodeCount;
|
|
13277
|
-
exports.checkExpressionLength = checkExpressionLength;
|
|
13278
|
-
exports.checkFunctionArgCount = checkFunctionArgCount;
|
|
13279
|
-
exports.checkGlobPatternLength = checkGlobPatternLength;
|
|
13280
|
-
exports.checkRegexPatternLength = checkRegexPatternLength;
|
|
13281
|
-
exports.countAstNodes = countAstNodes;
|
|
13282
13830
|
exports.createAftHelper = createAftHelper;
|
|
13283
13831
|
exports.createAftPayload = createAftPayload;
|
|
13284
13832
|
exports.createAftReplicaStickinessManager = createAftReplicaStickinessManager;
|
|
13285
13833
|
exports.createAftSigner = createAftSigner;
|
|
13286
13834
|
exports.createAftVerifier = createAftVerifier;
|
|
13287
|
-
exports.createAuthFunctionRegistry = createAuthFunctionRegistry;
|
|
13288
13835
|
exports.createEd25519Csr = createEd25519Csr;
|
|
13289
13836
|
exports.createEd25519CsrFromPem = createEd25519CsrFromPem;
|
|
13290
|
-
exports.createSecurityBindings = createSecurityBindings;
|
|
13291
13837
|
exports.createTestCA = createTestCA;
|
|
13292
|
-
exports.evaluate = evaluate;
|
|
13293
|
-
exports.evaluateAsBoolean = evaluateAsBoolean;
|
|
13294
13838
|
exports.extractCertificateInfo = extractCertificateInfo;
|
|
13295
13839
|
exports.extractLogicalHostsFromCert = extractLogicalHostsFromCert;
|
|
13296
13840
|
exports.extractNodeIdFromCert = extractNodeIdFromCert;
|
|
@@ -13298,18 +13842,12 @@ exports.extractSidFromCert = extractSidFromCert;
|
|
|
13298
13842
|
exports.extractSidFromSpiffeId = extractSidFromSpiffeId;
|
|
13299
13843
|
exports.extractSpiffeIdFromCert = extractSpiffeIdFromCert;
|
|
13300
13844
|
exports.formatCertificateInfo = formatCertificateInfo;
|
|
13301
|
-
exports.getTypeName = getTypeName;
|
|
13302
|
-
exports.isBuiltinFunction = isBuiltinFunction;
|
|
13303
|
-
exports.normalizeEncryptionLevelFromAlg = normalizeEncryptionLevelFromAlg;
|
|
13304
|
-
exports.normalizeJsValue = normalizeJsValue;
|
|
13305
13845
|
exports.normalizeStickinessMode = normalizeStickinessMode;
|
|
13306
|
-
exports.parse = parse;
|
|
13307
13846
|
exports.publicKeyFromX5c = publicKeyFromX5c;
|
|
13308
13847
|
exports.registerAdvancedSecurityFactories = registerAdvancedSecurityFactories;
|
|
13309
13848
|
exports.sealedEncryption = index$1;
|
|
13310
13849
|
exports.serializeAftClaims = serializeAftClaims;
|
|
13311
13850
|
exports.serializeAftHeader = serializeAftHeader;
|
|
13312
|
-
exports.tokenize = tokenize;
|
|
13313
13851
|
exports.utf8Decode = utf8Decode;
|
|
13314
13852
|
exports.validateJwkX5cCertificate = validateJwkX5cCertificate;
|
|
13315
13853
|
exports.verifyCertSidIntegrity = verifyCertSidIntegrity;
|