@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/browser/index.mjs
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { ExtensionManager, Expressions, Registry, AbstractResourceFactory } from '@naylence/factory';
|
|
2
|
-
import { ENCRYPTION_MANAGER_FACTORY_BASE_TYPE, getLogger, registerProfile, SECURITY_MANAGER_FACTORY_BASE_TYPE, KNOWN_POLICY_FIELDS, VALID_EFFECTS, compileGlobOnlyScopeRequirement, KNOWN_RULE_FIELDS, VALID_ACTIONS, compileGlobPattern, VALID_ORIGIN_TYPES, AUTHORIZATION_POLICY_FACTORY_BASE_TYPE, AuthorizationPolicyFactory, EncryptionResult, urlsafeBase64Decode, sealedDecrypt, sealedEncrypt, FIXED_PREFIX_LEN, urlsafeBase64Encode, EncryptionManagerFactory, requireCryptoSupport, SECURE_CHANNEL_MANAGER_FACTORY_BASE_TYPE, SecureChannelManagerFactory, ENVELOPE_SIGNER_FACTORY_BASE_TYPE, EnvelopeSignerFactory, SigningConfigClass, validateSigningKey, JWKValidationError, decodeBase64Url, canonicalJson, secureDigest, frameDigest, immutableHeaders, encodeUtf8, ENVELOPE_VERIFIER_FACTORY_BASE_TYPE, EnvelopeVerifierFactory, TrustStoreProviderFactory, TaskSpawner, getKeyStore, DefaultKeyManager, validateJwkComplete, currentTraceId, DeliveryOriginType, KEY_MANAGER_FACTORY_BASE_TYPE, KeyManagerFactory, KeyStoreFactory, BaseNodeEventListener, LOAD_BALANCER_STICKINESS_MANAGER_FACTORY_BASE_TYPE, LoadBalancerStickinessManagerFactory, REPLICA_STICKINESS_MANAGER_FACTORY_BASE_TYPE, ReplicaStickinessManagerFactory, color, AnsiColor, validateHostLogicals, HTTP_CONNECTION_GRANT_TYPE, formatTimestamp, jsonDumps, WELCOME_SERVICE_FACTORY_BASE_TYPE, WelcomeServiceFactory, NodePlacementStrategyFactory, TransportProvisionerFactory, TokenIssuerFactory, AuthorizerFactory, validateHostLogical, AuthInjectionStrategyFactory, CERTIFICATE_MANAGER_FACTORY_BASE_TYPE, CertificateManagerFactory, TRUST_STORE_PROVIDER_FACTORY_BASE_TYPE } from '@naylence/runtime';
|
|
2
|
+
import { ENCRYPTION_MANAGER_FACTORY_BASE_TYPE, getLogger, registerProfile, SECURITY_MANAGER_FACTORY_BASE_TYPE, KNOWN_POLICY_FIELDS, VALID_EFFECTS, compileGlobOnlyScopeRequirement, KNOWN_RULE_FIELDS, VALID_ACTIONS, compileGlobPattern, VALID_ORIGIN_TYPES, AUTHORIZATION_POLICY_FACTORY_BASE_TYPE, AuthorizationPolicyFactory, AUTHORIZATION_POLICY_SOURCE_FACTORY_BASE_TYPE, AuthorizationPolicySourceFactory, TokenProviderFactory, EncryptionResult, urlsafeBase64Decode, sealedDecrypt, sealedEncrypt, FIXED_PREFIX_LEN, urlsafeBase64Encode, EncryptionManagerFactory, requireCryptoSupport, SECURE_CHANNEL_MANAGER_FACTORY_BASE_TYPE, SecureChannelManagerFactory, ENVELOPE_SIGNER_FACTORY_BASE_TYPE, EnvelopeSignerFactory, SigningConfigClass, validateSigningKey, JWKValidationError, decodeBase64Url, canonicalJson, secureDigest, frameDigest, immutableHeaders, encodeUtf8, ENVELOPE_VERIFIER_FACTORY_BASE_TYPE, EnvelopeVerifierFactory, TrustStoreProviderFactory, TaskSpawner, getKeyStore, DefaultKeyManager, validateJwkComplete, currentTraceId, DeliveryOriginType, KEY_MANAGER_FACTORY_BASE_TYPE, KeyManagerFactory, KeyStoreFactory, BaseNodeEventListener, LOAD_BALANCER_STICKINESS_MANAGER_FACTORY_BASE_TYPE, LoadBalancerStickinessManagerFactory, REPLICA_STICKINESS_MANAGER_FACTORY_BASE_TYPE, ReplicaStickinessManagerFactory, color, AnsiColor, validateHostLogicals, HTTP_CONNECTION_GRANT_TYPE, formatTimestamp, jsonDumps, WELCOME_SERVICE_FACTORY_BASE_TYPE, WelcomeServiceFactory, NodePlacementStrategyFactory, TransportProvisionerFactory, TokenIssuerFactory, AuthorizerFactory, validateHostLogical, AuthInjectionStrategyFactory, CERTIFICATE_MANAGER_FACTORY_BASE_TYPE, CertificateManagerFactory, TRUST_STORE_PROVIDER_FACTORY_BASE_TYPE } from '@naylence/runtime';
|
|
3
3
|
import { sha256 } from '@noble/hashes/sha2';
|
|
4
4
|
import { generateFingerprintSync, localDeliveryContext, createFameEnvelope, generateId, formatAddress, FameAddress, SigningMaterial, DeliveryOriginType as DeliveryOriginType$1 } from '@naylence/core';
|
|
5
|
+
import { parse as parse$1 } from 'yaml';
|
|
5
6
|
import { AsnConvert, OctetString } from '@peculiar/asn1-schema';
|
|
6
7
|
import { Attributes, CertificationRequestInfo, CertificationRequest } from '@peculiar/asn1-csr';
|
|
7
8
|
import { Certificate, SubjectAlternativeName, NameConstraints, id_ce_subjectAltName, id_ce_nameConstraints, SubjectPublicKeyInfo, GeneralName, Extensions, Extension, Attribute, AlgorithmIdentifier, Name, RelativeDistinguishedName, AttributeTypeAndValue, AttributeValue, BasicConstraints, id_ce_basicConstraints, KeyUsageFlags, id_ce_keyUsage, KeyUsage, id_ce_subjectKeyIdentifier, SubjectKeyIdentifier, id_ce_authorityKeyIdentifier, AuthorityKeyIdentifier, KeyIdentifier, GeneralSubtrees, GeneralSubtree, TBSCertificate, Validity, Version, id_ce_extKeyUsage, ExtendedKeyUsage, id_kp_clientAuth, id_kp_serverAuth } from '@peculiar/asn1-x509';
|
|
@@ -23,6 +24,7 @@ import { X509Certificate } from '@peculiar/x509';
|
|
|
23
24
|
*/
|
|
24
25
|
const MODULES = [
|
|
25
26
|
"./security/auth/policy/advanced-authorization-policy-factory.js",
|
|
27
|
+
"./security/auth/policy/http-authorization-policy-source-factory.js",
|
|
26
28
|
"./security/cert/default-ca-service-factory.js",
|
|
27
29
|
"./security/cert/default-certificate-manager-factory.js",
|
|
28
30
|
"./security/cert/trust-store/browser-trust-store-provider-factory.js",
|
|
@@ -40,6 +42,7 @@ const MODULES = [
|
|
|
40
42
|
];
|
|
41
43
|
const MODULE_LOADERS = {
|
|
42
44
|
"./security/auth/policy/advanced-authorization-policy-factory.js": () => Promise.resolve().then(function () { return advancedAuthorizationPolicyFactory; }),
|
|
45
|
+
"./security/auth/policy/http-authorization-policy-source-factory.js": () => Promise.resolve().then(function () { return httpAuthorizationPolicySourceFactory; }),
|
|
43
46
|
"./security/cert/default-ca-service-factory.js": () => Promise.resolve().then(function () { return defaultCaServiceFactory; }),
|
|
44
47
|
"./security/cert/default-certificate-manager-factory.js": () => Promise.resolve().then(function () { return defaultCertificateManagerFactory; }),
|
|
45
48
|
"./security/cert/trust-store/browser-trust-store-provider-factory.js": () => Promise.resolve().then(function () { return browserTrustStoreProviderFactory; }),
|
|
@@ -56,7 +59,7 @@ const MODULE_LOADERS = {
|
|
|
56
59
|
"./welcome/advanced-welcome-service-factory.js": () => Promise.resolve().then(function () { return advancedWelcomeServiceFactory; }),
|
|
57
60
|
};
|
|
58
61
|
|
|
59
|
-
const logger$
|
|
62
|
+
const logger$i = getLogger("naylence.fame.security.encryption.encryption_manager_registry");
|
|
60
63
|
class EncryptionManagerFactoryRegistry {
|
|
61
64
|
constructor(autoDiscover = true) {
|
|
62
65
|
this.factories = [];
|
|
@@ -78,7 +81,7 @@ class EncryptionManagerFactoryRegistry {
|
|
|
78
81
|
let registeredCount = 0;
|
|
79
82
|
for (const [factoryName, info] of extensionInfos) {
|
|
80
83
|
if (factoryName === "CompositeEncryptionManager") {
|
|
81
|
-
logger$
|
|
84
|
+
logger$i.debug("skipping_composite_factory_to_avoid_circular_dependency", {
|
|
82
85
|
factory_name: factoryName,
|
|
83
86
|
});
|
|
84
87
|
continue;
|
|
@@ -88,7 +91,7 @@ class EncryptionManagerFactoryRegistry {
|
|
|
88
91
|
ExtensionManager.getGlobalFactory(ENCRYPTION_MANAGER_FACTORY_BASE_TYPE, factoryName));
|
|
89
92
|
this.registerFactory(factoryInstance, { autoDiscovered: true });
|
|
90
93
|
registeredCount += 1;
|
|
91
|
-
logger$
|
|
94
|
+
logger$i.debug("auto_discovered_factory", {
|
|
92
95
|
factory_name: factoryName,
|
|
93
96
|
factory_class: factoryInstance.constructor.name,
|
|
94
97
|
algorithms: factoryInstance.getSupportedAlgorithms(),
|
|
@@ -97,21 +100,21 @@ class EncryptionManagerFactoryRegistry {
|
|
|
97
100
|
});
|
|
98
101
|
}
|
|
99
102
|
catch (error) {
|
|
100
|
-
logger$
|
|
103
|
+
logger$i.warning("failed_to_auto_register_factory", {
|
|
101
104
|
factory_name: factoryName,
|
|
102
105
|
error: error instanceof Error ? error.message : String(error),
|
|
103
106
|
});
|
|
104
107
|
}
|
|
105
108
|
}
|
|
106
109
|
this.autoDiscovered = true;
|
|
107
|
-
logger$
|
|
110
|
+
logger$i.debug("completed_auto_discovery", {
|
|
108
111
|
registered_factories: registeredCount,
|
|
109
112
|
total_discovered: extensionInfos.size,
|
|
110
113
|
skipped_composite: true,
|
|
111
114
|
});
|
|
112
115
|
}
|
|
113
116
|
catch (error) {
|
|
114
|
-
logger$
|
|
117
|
+
logger$i.warning("failed_auto_discovery_of_factories", {
|
|
115
118
|
error: error instanceof Error ? error.message : String(error),
|
|
116
119
|
});
|
|
117
120
|
}
|
|
@@ -129,7 +132,7 @@ class EncryptionManagerFactoryRegistry {
|
|
|
129
132
|
const existing = this.algorithmToFactory.get(algorithm);
|
|
130
133
|
if (!existing || factory.getPriority() > existing.getPriority()) {
|
|
131
134
|
this.algorithmToFactory.set(algorithm, factory);
|
|
132
|
-
logger$
|
|
135
|
+
logger$i.debug("registered_algorithm_mapping", {
|
|
133
136
|
algorithm,
|
|
134
137
|
factory: factory.constructor.name,
|
|
135
138
|
priority: factory.getPriority(),
|
|
@@ -141,7 +144,7 @@ class EncryptionManagerFactoryRegistry {
|
|
|
141
144
|
typeFactories.push(factory);
|
|
142
145
|
typeFactories.sort((a, b) => b.getPriority() - a.getPriority());
|
|
143
146
|
this.typeToFactories.set(encryptionType, typeFactories);
|
|
144
|
-
logger$
|
|
147
|
+
logger$i.debug("registered_encryption_manager_factory", {
|
|
145
148
|
factory: factory.constructor.name,
|
|
146
149
|
encryption_type: encryptionType,
|
|
147
150
|
algorithms: factory.getSupportedAlgorithms(),
|
|
@@ -157,14 +160,14 @@ class EncryptionManagerFactoryRegistry {
|
|
|
157
160
|
this.ensureAutoDiscovery();
|
|
158
161
|
for (const factory of this.factories) {
|
|
159
162
|
if (factory.supportsOptions(opts ?? undefined)) {
|
|
160
|
-
logger$
|
|
163
|
+
logger$i.debug("found_factory_for_options", {
|
|
161
164
|
factory: factory.constructor.name,
|
|
162
165
|
encryption_type: factory.getEncryptionType(),
|
|
163
166
|
});
|
|
164
167
|
return factory;
|
|
165
168
|
}
|
|
166
169
|
}
|
|
167
|
-
logger$
|
|
170
|
+
logger$i.debug("no_factory_found_for_options", { opts });
|
|
168
171
|
return undefined;
|
|
169
172
|
}
|
|
170
173
|
getFactoriesByType(encryptionType) {
|
|
@@ -290,6 +293,7 @@ const SECURITY_PREFIX = "./security/";
|
|
|
290
293
|
const SECURITY_MODULES = MODULES.filter((spec) => spec.startsWith(SECURITY_PREFIX));
|
|
291
294
|
const EXTRA_MODULES = MODULES.filter((spec) => !spec.startsWith(SECURITY_PREFIX));
|
|
292
295
|
const NODE_ONLY_MODULES = new Set([
|
|
296
|
+
"./security/auth/policy/http-authorization-policy-source-factory.js",
|
|
293
297
|
"./security/cert/default-ca-service-factory.js",
|
|
294
298
|
"./security/cert/trust-store/node-trust-store-provider-factory.js",
|
|
295
299
|
]);
|
|
@@ -570,12 +574,12 @@ async function registerAdvancedSecurityFactories(registrar = Registry, options)
|
|
|
570
574
|
}
|
|
571
575
|
|
|
572
576
|
// This file is auto-generated during build - do not edit manually
|
|
573
|
-
// Generated from package.json version: 0.4.
|
|
577
|
+
// Generated from package.json version: 0.4.7
|
|
574
578
|
/**
|
|
575
579
|
* The package version, injected at build time.
|
|
576
580
|
* @internal
|
|
577
581
|
*/
|
|
578
|
-
const VERSION = '0.4.
|
|
582
|
+
const VERSION = '0.4.7';
|
|
579
583
|
|
|
580
584
|
async function registerAdvancedSecurityPluginFactories(registrar = Registry) {
|
|
581
585
|
await registerAdvancedSecurityFactories(registrar);
|
|
@@ -3386,7 +3390,7 @@ function getModule() {
|
|
|
3386
3390
|
}
|
|
3387
3391
|
return modulePromise;
|
|
3388
3392
|
}
|
|
3389
|
-
function normalizeConfig$
|
|
3393
|
+
function normalizeConfig$6(config) {
|
|
3390
3394
|
if (!config) {
|
|
3391
3395
|
throw new Error("AdvancedAuthorizationPolicyFactory requires a configuration with a policyDefinition");
|
|
3392
3396
|
}
|
|
@@ -3415,7 +3419,7 @@ function normalizeConfig$5(config) {
|
|
|
3415
3419
|
/**
|
|
3416
3420
|
* Factory metadata for registration.
|
|
3417
3421
|
*/
|
|
3418
|
-
const FACTORY_META$
|
|
3422
|
+
const FACTORY_META$f = {
|
|
3419
3423
|
base: AUTHORIZATION_POLICY_FACTORY_BASE_TYPE,
|
|
3420
3424
|
key: "AdvancedAuthorizationPolicy",
|
|
3421
3425
|
};
|
|
@@ -3434,7 +3438,7 @@ class AdvancedAuthorizationPolicyFactory extends AuthorizationPolicyFactory {
|
|
|
3434
3438
|
* @returns The created authorization policy
|
|
3435
3439
|
*/
|
|
3436
3440
|
async create(config) {
|
|
3437
|
-
const normalized = normalizeConfig$
|
|
3441
|
+
const normalized = normalizeConfig$6(config);
|
|
3438
3442
|
const { AdvancedAuthorizationPolicy } = await getModule();
|
|
3439
3443
|
return new AdvancedAuthorizationPolicy({
|
|
3440
3444
|
policyDefinition: normalized.policyDefinition,
|
|
@@ -3447,10 +3451,493 @@ class AdvancedAuthorizationPolicyFactory extends AuthorizationPolicyFactory {
|
|
|
3447
3451
|
var advancedAuthorizationPolicyFactory = /*#__PURE__*/Object.freeze({
|
|
3448
3452
|
__proto__: null,
|
|
3449
3453
|
AdvancedAuthorizationPolicyFactory: AdvancedAuthorizationPolicyFactory,
|
|
3450
|
-
FACTORY_META: FACTORY_META$
|
|
3454
|
+
FACTORY_META: FACTORY_META$f,
|
|
3451
3455
|
default: AdvancedAuthorizationPolicyFactory
|
|
3452
3456
|
});
|
|
3453
3457
|
|
|
3458
|
+
/**
|
|
3459
|
+
* HTTP-based authorization policy source.
|
|
3460
|
+
*
|
|
3461
|
+
* Loads authorization policies from an HTTP endpoint supporting JSON or YAML.
|
|
3462
|
+
* Supports bearer authentication via TokenProvider and HTTP caching via ETag.
|
|
3463
|
+
*
|
|
3464
|
+
* This is a Node.js-only implementation.
|
|
3465
|
+
*
|
|
3466
|
+
* @packageDocumentation
|
|
3467
|
+
*/
|
|
3468
|
+
const logger$h = getLogger("naylence.fame.security.auth.policy.http_authorization_policy_source");
|
|
3469
|
+
function isPlainObject(value) {
|
|
3470
|
+
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
3471
|
+
}
|
|
3472
|
+
function parseJson(content) {
|
|
3473
|
+
const parsed = JSON.parse(content);
|
|
3474
|
+
if (!isPlainObject(parsed)) {
|
|
3475
|
+
throw new Error("Parsed JSON policy must be an object");
|
|
3476
|
+
}
|
|
3477
|
+
return parsed;
|
|
3478
|
+
}
|
|
3479
|
+
function parseYamlContent(content) {
|
|
3480
|
+
const parsed = parse$1(content ?? "");
|
|
3481
|
+
if (parsed == null) {
|
|
3482
|
+
return {};
|
|
3483
|
+
}
|
|
3484
|
+
if (!isPlainObject(parsed)) {
|
|
3485
|
+
throw new Error("Parsed YAML policy must be an object");
|
|
3486
|
+
}
|
|
3487
|
+
return parsed;
|
|
3488
|
+
}
|
|
3489
|
+
/**
|
|
3490
|
+
* Detect whether content is JSON or YAML based on Content-Type header.
|
|
3491
|
+
* Falls back to sniffing the content if Content-Type is not definitive.
|
|
3492
|
+
*/
|
|
3493
|
+
function detectFormat(contentType, content) {
|
|
3494
|
+
if (contentType) {
|
|
3495
|
+
const lower = contentType.toLowerCase();
|
|
3496
|
+
if (lower.includes("application/json") ||
|
|
3497
|
+
lower.includes("text/json")) {
|
|
3498
|
+
return "json";
|
|
3499
|
+
}
|
|
3500
|
+
if (lower.includes("application/yaml") ||
|
|
3501
|
+
lower.includes("application/x-yaml") ||
|
|
3502
|
+
lower.includes("text/yaml") ||
|
|
3503
|
+
lower.includes("text/x-yaml")) {
|
|
3504
|
+
return "yaml";
|
|
3505
|
+
}
|
|
3506
|
+
}
|
|
3507
|
+
// Sniff by first non-whitespace character
|
|
3508
|
+
const trimmed = content.trimStart();
|
|
3509
|
+
if (trimmed.startsWith("{") || trimmed.startsWith("[")) {
|
|
3510
|
+
return "json";
|
|
3511
|
+
}
|
|
3512
|
+
// Default to YAML
|
|
3513
|
+
return "yaml";
|
|
3514
|
+
}
|
|
3515
|
+
/**
|
|
3516
|
+
* Parse Cache-Control header to extract max-age value.
|
|
3517
|
+
*/
|
|
3518
|
+
function parseMaxAge(cacheControl) {
|
|
3519
|
+
if (!cacheControl) {
|
|
3520
|
+
return undefined;
|
|
3521
|
+
}
|
|
3522
|
+
const match = cacheControl.match(/max-age\s*=\s*(\d+)/i);
|
|
3523
|
+
if (match && match[1]) {
|
|
3524
|
+
const seconds = parseInt(match[1], 10);
|
|
3525
|
+
if (Number.isFinite(seconds) && seconds >= 0) {
|
|
3526
|
+
return seconds;
|
|
3527
|
+
}
|
|
3528
|
+
}
|
|
3529
|
+
return undefined;
|
|
3530
|
+
}
|
|
3531
|
+
/**
|
|
3532
|
+
* An authorization policy source that loads policy definitions from an HTTP endpoint.
|
|
3533
|
+
*
|
|
3534
|
+
* Supports JSON and YAML formats, bearer authentication via TokenProvider,
|
|
3535
|
+
* and HTTP caching via ETag and Cache-Control headers.
|
|
3536
|
+
*
|
|
3537
|
+
* This is a Node.js-only implementation that uses fetch.
|
|
3538
|
+
*/
|
|
3539
|
+
class HttpAuthorizationPolicySource {
|
|
3540
|
+
constructor(options) {
|
|
3541
|
+
this.cachedState = null;
|
|
3542
|
+
this.inflightFetch = null;
|
|
3543
|
+
if (!options.url || typeof options.url !== "string") {
|
|
3544
|
+
throw new Error("HttpAuthorizationPolicySource requires a valid URL");
|
|
3545
|
+
}
|
|
3546
|
+
this.url = options.url;
|
|
3547
|
+
this.method = options.method ?? "GET";
|
|
3548
|
+
this.timeoutMs = options.timeoutMs ?? 30000;
|
|
3549
|
+
this.headers = { ...options.headers };
|
|
3550
|
+
this.tokenProvider = options.tokenProvider;
|
|
3551
|
+
this.bearerPrefix = options.bearerPrefix ?? "Bearer ";
|
|
3552
|
+
this.policyFactoryConfig = options.policyFactory;
|
|
3553
|
+
this.cacheTtlMs = options.cacheTtlMs ?? 300000; // 5 minutes default
|
|
3554
|
+
}
|
|
3555
|
+
/**
|
|
3556
|
+
* Loads the authorization policy from the configured HTTP endpoint.
|
|
3557
|
+
*
|
|
3558
|
+
* Returns a cached policy if still fresh (based on TTL or cache headers).
|
|
3559
|
+
* Multiple concurrent calls are de-duplicated (single-flight pattern).
|
|
3560
|
+
*
|
|
3561
|
+
* @returns The loaded authorization policy
|
|
3562
|
+
*/
|
|
3563
|
+
async loadPolicy() {
|
|
3564
|
+
// Return cached policy if still fresh
|
|
3565
|
+
if (this.cachedState && this.isCacheFresh()) {
|
|
3566
|
+
logger$h.debug("returning_cached_policy", {
|
|
3567
|
+
url: this.url,
|
|
3568
|
+
fetchedAt: this.cachedState.metadata.fetchedAt,
|
|
3569
|
+
expiresAt: this.cachedState.metadata.expiresAt,
|
|
3570
|
+
});
|
|
3571
|
+
return this.cachedState.policy;
|
|
3572
|
+
}
|
|
3573
|
+
// De-duplicate concurrent requests
|
|
3574
|
+
if (this.inflightFetch) {
|
|
3575
|
+
return this.inflightFetch;
|
|
3576
|
+
}
|
|
3577
|
+
this.inflightFetch = this.fetchPolicy(false);
|
|
3578
|
+
try {
|
|
3579
|
+
return await this.inflightFetch;
|
|
3580
|
+
}
|
|
3581
|
+
finally {
|
|
3582
|
+
this.inflightFetch = null;
|
|
3583
|
+
}
|
|
3584
|
+
}
|
|
3585
|
+
/**
|
|
3586
|
+
* Forces a reload of the policy from the HTTP endpoint.
|
|
3587
|
+
*
|
|
3588
|
+
* Bypasses cache freshness checks and always fetches from the server.
|
|
3589
|
+
* If the fetch fails, the existing cached policy is preserved and the error is thrown.
|
|
3590
|
+
*
|
|
3591
|
+
* @returns The reloaded authorization policy
|
|
3592
|
+
*/
|
|
3593
|
+
async reloadPolicy() {
|
|
3594
|
+
// Clear inflight to force a new request
|
|
3595
|
+
this.inflightFetch = null;
|
|
3596
|
+
return this.fetchPolicy(true);
|
|
3597
|
+
}
|
|
3598
|
+
/**
|
|
3599
|
+
* Clears the cached policy, forcing a fresh fetch on the next loadPolicy() call.
|
|
3600
|
+
*/
|
|
3601
|
+
clearCache() {
|
|
3602
|
+
this.cachedState = null;
|
|
3603
|
+
this.inflightFetch = null;
|
|
3604
|
+
}
|
|
3605
|
+
/**
|
|
3606
|
+
* Returns metadata about the last successful fetch.
|
|
3607
|
+
*
|
|
3608
|
+
* Useful for verification, monitoring, or debugging.
|
|
3609
|
+
*/
|
|
3610
|
+
getMetadata() {
|
|
3611
|
+
return this.cachedState?.metadata;
|
|
3612
|
+
}
|
|
3613
|
+
/**
|
|
3614
|
+
* Returns the raw policy definition from the last successful fetch.
|
|
3615
|
+
*
|
|
3616
|
+
* Useful for verification or reprocessing.
|
|
3617
|
+
*/
|
|
3618
|
+
getRawDefinition() {
|
|
3619
|
+
return this.cachedState?.rawDefinition;
|
|
3620
|
+
}
|
|
3621
|
+
isCacheFresh() {
|
|
3622
|
+
if (!this.cachedState) {
|
|
3623
|
+
return false;
|
|
3624
|
+
}
|
|
3625
|
+
const now = Date.now();
|
|
3626
|
+
const { expiresAt } = this.cachedState.metadata;
|
|
3627
|
+
if (expiresAt !== undefined) {
|
|
3628
|
+
return now < expiresAt;
|
|
3629
|
+
}
|
|
3630
|
+
// No expiration info, check against default TTL
|
|
3631
|
+
const fetchedAt = this.cachedState.metadata.fetchedAt;
|
|
3632
|
+
return now < fetchedAt + this.cacheTtlMs;
|
|
3633
|
+
}
|
|
3634
|
+
async fetchPolicy(forceRefresh) {
|
|
3635
|
+
logger$h.debug("fetching_policy", {
|
|
3636
|
+
url: this.url,
|
|
3637
|
+
method: this.method,
|
|
3638
|
+
forceRefresh,
|
|
3639
|
+
});
|
|
3640
|
+
const requestHeaders = {
|
|
3641
|
+
Accept: "application/json, application/yaml, text/yaml, */*",
|
|
3642
|
+
...this.headers,
|
|
3643
|
+
};
|
|
3644
|
+
// Add bearer token if token provider is configured
|
|
3645
|
+
if (this.tokenProvider) {
|
|
3646
|
+
try {
|
|
3647
|
+
const token = await this.tokenProvider.getToken();
|
|
3648
|
+
if (token && token.value) {
|
|
3649
|
+
requestHeaders["Authorization"] = `${this.bearerPrefix}${token.value}`;
|
|
3650
|
+
logger$h.debug("added_bearer_token", { url: this.url });
|
|
3651
|
+
}
|
|
3652
|
+
}
|
|
3653
|
+
catch (error) {
|
|
3654
|
+
logger$h.warning("token_provider_failed", {
|
|
3655
|
+
url: this.url,
|
|
3656
|
+
error: error instanceof Error ? error.message : String(error),
|
|
3657
|
+
});
|
|
3658
|
+
// Continue without token - let the server decide if auth is required
|
|
3659
|
+
}
|
|
3660
|
+
}
|
|
3661
|
+
// Add If-None-Match header for conditional request if we have a cached ETag
|
|
3662
|
+
// and this is not a forced refresh
|
|
3663
|
+
if (!forceRefresh && this.cachedState?.metadata.etag) {
|
|
3664
|
+
requestHeaders["If-None-Match"] = this.cachedState.metadata.etag;
|
|
3665
|
+
}
|
|
3666
|
+
const controller = new AbortController();
|
|
3667
|
+
const timeoutId = setTimeout(() => controller.abort(), this.timeoutMs);
|
|
3668
|
+
try {
|
|
3669
|
+
const response = await fetch(this.url, {
|
|
3670
|
+
method: this.method,
|
|
3671
|
+
headers: requestHeaders,
|
|
3672
|
+
signal: controller.signal,
|
|
3673
|
+
});
|
|
3674
|
+
clearTimeout(timeoutId);
|
|
3675
|
+
// Handle 304 Not Modified - return cached policy
|
|
3676
|
+
if (response.status === 304 && this.cachedState) {
|
|
3677
|
+
logger$h.debug("policy_not_modified", {
|
|
3678
|
+
url: this.url,
|
|
3679
|
+
etag: this.cachedState.metadata.etag,
|
|
3680
|
+
});
|
|
3681
|
+
// Update freshness timestamps
|
|
3682
|
+
const now = Date.now();
|
|
3683
|
+
const cacheControl = response.headers.get("Cache-Control");
|
|
3684
|
+
const maxAgeSeconds = parseMaxAge(cacheControl);
|
|
3685
|
+
const expiresAt = maxAgeSeconds !== undefined
|
|
3686
|
+
? now + maxAgeSeconds * 1000
|
|
3687
|
+
: now + this.cacheTtlMs;
|
|
3688
|
+
this.cachedState = {
|
|
3689
|
+
...this.cachedState,
|
|
3690
|
+
metadata: {
|
|
3691
|
+
...this.cachedState.metadata,
|
|
3692
|
+
fetchedAt: now,
|
|
3693
|
+
maxAgeSeconds,
|
|
3694
|
+
expiresAt,
|
|
3695
|
+
},
|
|
3696
|
+
};
|
|
3697
|
+
return this.cachedState.policy;
|
|
3698
|
+
}
|
|
3699
|
+
if (!response.ok) {
|
|
3700
|
+
const errorMessage = `HTTP ${response.status}: ${response.statusText}`;
|
|
3701
|
+
logger$h.error("policy_fetch_failed", {
|
|
3702
|
+
url: this.url,
|
|
3703
|
+
status: response.status,
|
|
3704
|
+
statusText: response.statusText,
|
|
3705
|
+
});
|
|
3706
|
+
// If we have a cached policy, preserve it and throw
|
|
3707
|
+
if (this.cachedState) {
|
|
3708
|
+
throw new Error(`Failed to fetch policy from ${this.url}: ${errorMessage}. ` +
|
|
3709
|
+
"Using last known good policy.");
|
|
3710
|
+
}
|
|
3711
|
+
throw new Error(`Failed to fetch policy from ${this.url}: ${errorMessage}`);
|
|
3712
|
+
}
|
|
3713
|
+
// Parse the response
|
|
3714
|
+
const contentType = response.headers.get("Content-Type");
|
|
3715
|
+
const content = await response.text();
|
|
3716
|
+
const format = detectFormat(contentType, content);
|
|
3717
|
+
let policyDefinition;
|
|
3718
|
+
try {
|
|
3719
|
+
if (format === "json") {
|
|
3720
|
+
policyDefinition = parseJson(content);
|
|
3721
|
+
}
|
|
3722
|
+
else {
|
|
3723
|
+
policyDefinition = parseYamlContent(content);
|
|
3724
|
+
}
|
|
3725
|
+
}
|
|
3726
|
+
catch (parseError) {
|
|
3727
|
+
const message = parseError instanceof Error
|
|
3728
|
+
? parseError.message
|
|
3729
|
+
: String(parseError);
|
|
3730
|
+
logger$h.error("policy_parse_failed", {
|
|
3731
|
+
url: this.url,
|
|
3732
|
+
format,
|
|
3733
|
+
error: message,
|
|
3734
|
+
});
|
|
3735
|
+
// Preserve cached policy on parse failure
|
|
3736
|
+
if (this.cachedState) {
|
|
3737
|
+
throw new Error(`Failed to parse policy from ${this.url}: ${message}. ` +
|
|
3738
|
+
"Using last known good policy.");
|
|
3739
|
+
}
|
|
3740
|
+
throw new Error(`Failed to parse policy from ${this.url}: ${message}`);
|
|
3741
|
+
}
|
|
3742
|
+
logger$h.debug("parsed_policy_definition", {
|
|
3743
|
+
url: this.url,
|
|
3744
|
+
format,
|
|
3745
|
+
hasType: "type" in policyDefinition,
|
|
3746
|
+
});
|
|
3747
|
+
// Build the policy using the factory
|
|
3748
|
+
const policy = await this.buildPolicy(policyDefinition);
|
|
3749
|
+
// Update cache
|
|
3750
|
+
const now = Date.now();
|
|
3751
|
+
const etag = response.headers.get("ETag") ?? undefined;
|
|
3752
|
+
const cacheControl = response.headers.get("Cache-Control");
|
|
3753
|
+
const maxAgeSeconds = parseMaxAge(cacheControl);
|
|
3754
|
+
const expiresAt = maxAgeSeconds !== undefined
|
|
3755
|
+
? now + maxAgeSeconds * 1000
|
|
3756
|
+
: now + this.cacheTtlMs;
|
|
3757
|
+
this.cachedState = {
|
|
3758
|
+
policy,
|
|
3759
|
+
rawDefinition: policyDefinition,
|
|
3760
|
+
metadata: {
|
|
3761
|
+
url: this.url,
|
|
3762
|
+
status: response.status,
|
|
3763
|
+
etag,
|
|
3764
|
+
fetchedAt: now,
|
|
3765
|
+
maxAgeSeconds,
|
|
3766
|
+
expiresAt,
|
|
3767
|
+
},
|
|
3768
|
+
};
|
|
3769
|
+
logger$h.info("loaded_policy_from_http", {
|
|
3770
|
+
url: this.url,
|
|
3771
|
+
status: response.status,
|
|
3772
|
+
format,
|
|
3773
|
+
etag,
|
|
3774
|
+
maxAgeSeconds,
|
|
3775
|
+
});
|
|
3776
|
+
return policy;
|
|
3777
|
+
}
|
|
3778
|
+
catch (error) {
|
|
3779
|
+
clearTimeout(timeoutId);
|
|
3780
|
+
if (error instanceof Error && error.name === "AbortError") {
|
|
3781
|
+
const timeoutError = new Error(`Request to ${this.url} timed out after ${this.timeoutMs}ms`);
|
|
3782
|
+
logger$h.error("policy_fetch_timeout", {
|
|
3783
|
+
url: this.url,
|
|
3784
|
+
timeoutMs: this.timeoutMs,
|
|
3785
|
+
});
|
|
3786
|
+
// Preserve cached policy on timeout
|
|
3787
|
+
if (this.cachedState) {
|
|
3788
|
+
throw timeoutError;
|
|
3789
|
+
}
|
|
3790
|
+
throw timeoutError;
|
|
3791
|
+
}
|
|
3792
|
+
throw error;
|
|
3793
|
+
}
|
|
3794
|
+
}
|
|
3795
|
+
async buildPolicy(policyDefinition) {
|
|
3796
|
+
// Determine the factory configuration to use
|
|
3797
|
+
const factoryConfig = this.policyFactoryConfig ?? policyDefinition;
|
|
3798
|
+
// Ensure we have a type field for the factory
|
|
3799
|
+
if (!("type" in factoryConfig) || typeof factoryConfig.type !== "string") {
|
|
3800
|
+
logger$h.warning("policy_type_missing_defaulting_to_basic", {
|
|
3801
|
+
url: this.url,
|
|
3802
|
+
});
|
|
3803
|
+
factoryConfig.type = "BasicAuthorizationPolicy";
|
|
3804
|
+
}
|
|
3805
|
+
// Build the factory config with the policy definition
|
|
3806
|
+
// The response content IS the policy definition, so we extract the type
|
|
3807
|
+
// and wrap the remaining content as the policyDefinition
|
|
3808
|
+
const { type: definitionType, ...restOfDefinition } = policyDefinition;
|
|
3809
|
+
const resolvedType = typeof definitionType === "string" && definitionType.trim().length > 0
|
|
3810
|
+
? definitionType
|
|
3811
|
+
: factoryConfig.type;
|
|
3812
|
+
const mergedConfig = this.policyFactoryConfig != null
|
|
3813
|
+
? { ...this.policyFactoryConfig, policyDefinition }
|
|
3814
|
+
: { type: resolvedType, policyDefinition: restOfDefinition };
|
|
3815
|
+
const policy = await AuthorizationPolicyFactory.createAuthorizationPolicy(mergedConfig);
|
|
3816
|
+
if (!policy) {
|
|
3817
|
+
throw new Error(`Failed to create authorization policy from ${this.url}`);
|
|
3818
|
+
}
|
|
3819
|
+
return policy;
|
|
3820
|
+
}
|
|
3821
|
+
}
|
|
3822
|
+
|
|
3823
|
+
var httpAuthorizationPolicySource = /*#__PURE__*/Object.freeze({
|
|
3824
|
+
__proto__: null,
|
|
3825
|
+
HttpAuthorizationPolicySource: HttpAuthorizationPolicySource
|
|
3826
|
+
});
|
|
3827
|
+
|
|
3828
|
+
/**
|
|
3829
|
+
* Factory for creating HttpAuthorizationPolicySource instances.
|
|
3830
|
+
*
|
|
3831
|
+
* @packageDocumentation
|
|
3832
|
+
*/
|
|
3833
|
+
let httpModulePromise = null;
|
|
3834
|
+
async function getHttpModule() {
|
|
3835
|
+
if (!httpModulePromise) {
|
|
3836
|
+
httpModulePromise = Promise.resolve().then(function () { return httpAuthorizationPolicySource; });
|
|
3837
|
+
}
|
|
3838
|
+
return httpModulePromise;
|
|
3839
|
+
}
|
|
3840
|
+
function normalizeConfig$5(config) {
|
|
3841
|
+
if (!config) {
|
|
3842
|
+
throw new Error("HttpAuthorizationPolicySourceFactory requires a configuration with a url");
|
|
3843
|
+
}
|
|
3844
|
+
const candidate = config;
|
|
3845
|
+
const url = candidate.url;
|
|
3846
|
+
if (typeof url !== "string" || url.trim().length === 0) {
|
|
3847
|
+
throw new Error("HttpAuthorizationPolicySourceConfig requires a non-empty url");
|
|
3848
|
+
}
|
|
3849
|
+
// Support both camelCase and snake_case
|
|
3850
|
+
const method = candidate.method ?? "GET";
|
|
3851
|
+
if (!["GET", "POST", "PUT"].includes(method)) {
|
|
3852
|
+
throw new Error(`Invalid method "${String(method)}". Must be "GET", "POST", or "PUT"`);
|
|
3853
|
+
}
|
|
3854
|
+
const timeoutMs = candidate.timeout_ms ??
|
|
3855
|
+
candidate.timeoutMs ??
|
|
3856
|
+
30000;
|
|
3857
|
+
if (typeof timeoutMs !== "number" || !Number.isFinite(timeoutMs) || timeoutMs <= 0) {
|
|
3858
|
+
throw new Error("timeout_ms must be a positive number");
|
|
3859
|
+
}
|
|
3860
|
+
const headers = candidate.headers;
|
|
3861
|
+
if (headers !== undefined && typeof headers !== "object") {
|
|
3862
|
+
throw new Error("headers must be an object");
|
|
3863
|
+
}
|
|
3864
|
+
const tokenProviderConfig = candidate.token_provider ??
|
|
3865
|
+
candidate.tokenProvider;
|
|
3866
|
+
const bearerPrefix = candidate.bearer_prefix ??
|
|
3867
|
+
candidate.bearerPrefix ??
|
|
3868
|
+
"Bearer ";
|
|
3869
|
+
const policyFactory = candidate.policy_factory ??
|
|
3870
|
+
candidate.policyFactory;
|
|
3871
|
+
const cacheTtlMs = candidate.cache_ttl_ms ??
|
|
3872
|
+
candidate.cacheTtlMs ??
|
|
3873
|
+
300000;
|
|
3874
|
+
if (typeof cacheTtlMs !== "number" || !Number.isFinite(cacheTtlMs) || cacheTtlMs < 0) {
|
|
3875
|
+
throw new Error("cache_ttl_ms must be a non-negative number");
|
|
3876
|
+
}
|
|
3877
|
+
return {
|
|
3878
|
+
url: url.trim(),
|
|
3879
|
+
method,
|
|
3880
|
+
timeoutMs,
|
|
3881
|
+
headers,
|
|
3882
|
+
tokenProviderConfig,
|
|
3883
|
+
bearerPrefix,
|
|
3884
|
+
policyFactory,
|
|
3885
|
+
cacheTtlMs,
|
|
3886
|
+
};
|
|
3887
|
+
}
|
|
3888
|
+
/**
|
|
3889
|
+
* Factory metadata for registration.
|
|
3890
|
+
*/
|
|
3891
|
+
const FACTORY_META$e = {
|
|
3892
|
+
base: AUTHORIZATION_POLICY_SOURCE_FACTORY_BASE_TYPE,
|
|
3893
|
+
key: "HttpAuthorizationPolicySource",
|
|
3894
|
+
};
|
|
3895
|
+
/**
|
|
3896
|
+
* Factory for creating HttpAuthorizationPolicySource instances.
|
|
3897
|
+
*
|
|
3898
|
+
* This factory uses lazy loading to avoid pulling in Node.js-specific
|
|
3899
|
+
* code (fetch operations) in browser environments where it may not work.
|
|
3900
|
+
*/
|
|
3901
|
+
class HttpAuthorizationPolicySourceFactory extends AuthorizationPolicySourceFactory {
|
|
3902
|
+
constructor() {
|
|
3903
|
+
super(...arguments);
|
|
3904
|
+
this.type = "HttpAuthorizationPolicySource";
|
|
3905
|
+
}
|
|
3906
|
+
/**
|
|
3907
|
+
* Creates an HttpAuthorizationPolicySource from the given configuration.
|
|
3908
|
+
*
|
|
3909
|
+
* @param config - Configuration specifying the policy URL and options
|
|
3910
|
+
* @returns The created policy source
|
|
3911
|
+
*/
|
|
3912
|
+
async create(config) {
|
|
3913
|
+
const normalized = normalizeConfig$5(config);
|
|
3914
|
+
// Create token provider if configured
|
|
3915
|
+
let tokenProvider;
|
|
3916
|
+
if (normalized.tokenProviderConfig) {
|
|
3917
|
+
tokenProvider = await TokenProviderFactory.createTokenProvider(normalized.tokenProviderConfig);
|
|
3918
|
+
}
|
|
3919
|
+
const { HttpAuthorizationPolicySource } = await getHttpModule();
|
|
3920
|
+
const options = {
|
|
3921
|
+
url: normalized.url,
|
|
3922
|
+
method: normalized.method,
|
|
3923
|
+
timeoutMs: normalized.timeoutMs,
|
|
3924
|
+
headers: normalized.headers,
|
|
3925
|
+
tokenProvider,
|
|
3926
|
+
bearerPrefix: normalized.bearerPrefix,
|
|
3927
|
+
policyFactory: normalized.policyFactory,
|
|
3928
|
+
cacheTtlMs: normalized.cacheTtlMs,
|
|
3929
|
+
};
|
|
3930
|
+
return new HttpAuthorizationPolicySource(options);
|
|
3931
|
+
}
|
|
3932
|
+
}
|
|
3933
|
+
|
|
3934
|
+
var httpAuthorizationPolicySourceFactory = /*#__PURE__*/Object.freeze({
|
|
3935
|
+
__proto__: null,
|
|
3936
|
+
FACTORY_META: FACTORY_META$e,
|
|
3937
|
+
HttpAuthorizationPolicySourceFactory: HttpAuthorizationPolicySourceFactory,
|
|
3938
|
+
default: HttpAuthorizationPolicySourceFactory
|
|
3939
|
+
});
|
|
3940
|
+
|
|
3454
3941
|
const logger$g = getLogger("naylence.fame.security.cert.util");
|
|
3455
3942
|
const CACHE_LIMIT = 512;
|
|
3456
3943
|
const OID_ED25519 = "1.3.101.112";
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
export { VERSION } from "./version.js";
|
|
8
8
|
// Expression engine (browser-safe, uses @noble/hashes)
|
|
9
|
-
export * from "./naylence/fame/expr/index.js";
|
|
9
|
+
// export * from "./naylence/fame/expr/index.js";
|
|
10
10
|
// Authorization policy with expression support (browser-safe)
|
|
11
11
|
export * from "./naylence/fame/security/auth/index.js";
|
|
12
12
|
export { validateJwkX5cCertificate, publicKeyFromX5c, } from "./naylence/fame/security/cert/util.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"advanced-security-isomorphic.js","sourceRoot":"","sources":["../../src/advanced-security-isomorphic.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC,uDAAuD;AACvD,
|
|
1
|
+
{"version":3,"file":"advanced-security-isomorphic.js","sourceRoot":"","sources":["../../src/advanced-security-isomorphic.ts"],"names":[],"mappings":"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"}
|