@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/index.cjs
CHANGED
|
@@ -9,6 +9,7 @@ var ed25519 = require('@noble/ed25519');
|
|
|
9
9
|
var sha2_js = require('@noble/hashes/sha2.js');
|
|
10
10
|
var core = require('@naylence/core');
|
|
11
11
|
var sha2 = require('@noble/hashes/sha2');
|
|
12
|
+
var yaml = require('yaml');
|
|
12
13
|
var chacha_js = require('@noble/ciphers/chacha.js');
|
|
13
14
|
var ed25519_js = require('@noble/curves/ed25519.js');
|
|
14
15
|
var hkdf_js = require('@noble/hashes/hkdf.js');
|
|
@@ -18,12 +19,12 @@ var sha256_js = require('@noble/hashes/sha256.js');
|
|
|
18
19
|
var x509 = require('@peculiar/x509');
|
|
19
20
|
|
|
20
21
|
// This file is auto-generated during build - do not edit manually
|
|
21
|
-
// Generated from package.json version: 0.4.
|
|
22
|
+
// Generated from package.json version: 0.4.7
|
|
22
23
|
/**
|
|
23
24
|
* The package version, injected at build time.
|
|
24
25
|
* @internal
|
|
25
26
|
*/
|
|
26
|
-
const VERSION = '0.4.
|
|
27
|
+
const VERSION = '0.4.7';
|
|
27
28
|
|
|
28
29
|
/**
|
|
29
30
|
* Abstract Syntax Tree (AST) node types for the expression language.
|
|
@@ -110,55 +111,6 @@ function calculateAstDepth(node) {
|
|
|
110
111
|
Math.max(calculateAstDepth(node.condition), calculateAstDepth(node.consequent), calculateAstDepth(node.alternate)));
|
|
111
112
|
}
|
|
112
113
|
}
|
|
113
|
-
/**
|
|
114
|
-
* Returns a human-readable representation of an AST node for debugging.
|
|
115
|
-
*/
|
|
116
|
-
function astToString(node, indent = 0) {
|
|
117
|
-
const prefix = " ".repeat(indent);
|
|
118
|
-
switch (node.type) {
|
|
119
|
-
case "StringLiteral":
|
|
120
|
-
return `${prefix}String: "${node.value}"`;
|
|
121
|
-
case "NumberLiteral":
|
|
122
|
-
return `${prefix}Number: ${node.value}`;
|
|
123
|
-
case "BooleanLiteral":
|
|
124
|
-
return `${prefix}Boolean: ${node.value}`;
|
|
125
|
-
case "NullLiteral":
|
|
126
|
-
return `${prefix}Null`;
|
|
127
|
-
case "ArrayLiteral":
|
|
128
|
-
return (`${prefix}Array:\n` +
|
|
129
|
-
node.elements.map((e) => astToString(e, indent + 1)).join("\n"));
|
|
130
|
-
case "Identifier":
|
|
131
|
-
return `${prefix}Identifier: ${node.name}`;
|
|
132
|
-
case "MemberAccess":
|
|
133
|
-
return (`${prefix}MemberAccess: .${node.property}\n` +
|
|
134
|
-
astToString(node.object, indent + 1));
|
|
135
|
-
case "IndexAccess":
|
|
136
|
-
return (`${prefix}IndexAccess:\n` +
|
|
137
|
-
`${prefix} object:\n` +
|
|
138
|
-
astToString(node.object, indent + 2) +
|
|
139
|
-
`\n${prefix} index:\n` +
|
|
140
|
-
astToString(node.index, indent + 2));
|
|
141
|
-
case "FunctionCall":
|
|
142
|
-
return (`${prefix}FunctionCall: ${node.name}\n` +
|
|
143
|
-
node.args.map((a) => astToString(a, indent + 1)).join("\n"));
|
|
144
|
-
case "UnaryOp":
|
|
145
|
-
return (`${prefix}UnaryOp: ${node.operator}\n` +
|
|
146
|
-
astToString(node.operand, indent + 1));
|
|
147
|
-
case "BinaryOp":
|
|
148
|
-
return (`${prefix}BinaryOp: ${node.operator}\n` +
|
|
149
|
-
astToString(node.left, indent + 1) +
|
|
150
|
-
"\n" +
|
|
151
|
-
astToString(node.right, indent + 1));
|
|
152
|
-
case "TernaryOp":
|
|
153
|
-
return (`${prefix}TernaryOp:\n` +
|
|
154
|
-
`${prefix} condition:\n` +
|
|
155
|
-
astToString(node.condition, indent + 2) +
|
|
156
|
-
`\n${prefix} consequent:\n` +
|
|
157
|
-
astToString(node.consequent, indent + 2) +
|
|
158
|
-
`\n${prefix} alternate:\n` +
|
|
159
|
-
astToString(node.alternate, indent + 2));
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
114
|
|
|
163
115
|
/**
|
|
164
116
|
* Error types for the expression evaluation engine.
|
|
@@ -225,18 +177,6 @@ class TypeError extends EvaluationError {
|
|
|
225
177
|
this.actual = actual;
|
|
226
178
|
}
|
|
227
179
|
}
|
|
228
|
-
/**
|
|
229
|
-
* Error thrown when expression limits are exceeded.
|
|
230
|
-
*/
|
|
231
|
-
class LimitExceededError extends ExpressionError {
|
|
232
|
-
constructor(limitName, limit, actual) {
|
|
233
|
-
super(`Limit exceeded: ${limitName} (limit: ${limit}, actual: ${actual})`);
|
|
234
|
-
this.name = "LimitExceededError";
|
|
235
|
-
this.limitName = limitName;
|
|
236
|
-
this.limit = limit;
|
|
237
|
-
this.actual = actual;
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
180
|
/**
|
|
241
181
|
* Error thrown when a built-in function encounters an error.
|
|
242
182
|
*/
|
|
@@ -1553,12 +1493,6 @@ function callBuiltin(name, args, context, functions = BUILTIN_FUNCTIONS) {
|
|
|
1553
1493
|
}
|
|
1554
1494
|
return fn(args, context);
|
|
1555
1495
|
}
|
|
1556
|
-
/**
|
|
1557
|
-
* Checks if a name is a built-in function.
|
|
1558
|
-
*/
|
|
1559
|
-
function isBuiltinFunction(name, functions = BUILTIN_FUNCTIONS) {
|
|
1560
|
-
return functions.has(name);
|
|
1561
|
-
}
|
|
1562
1496
|
|
|
1563
1497
|
/**
|
|
1564
1498
|
* Expression evaluator.
|
|
@@ -1905,24 +1839,6 @@ class Evaluator {
|
|
|
1905
1839
|
return false;
|
|
1906
1840
|
}
|
|
1907
1841
|
}
|
|
1908
|
-
/**
|
|
1909
|
-
* Evaluates an AST against a context and returns the result.
|
|
1910
|
-
*
|
|
1911
|
-
* @param ast - The AST to evaluate
|
|
1912
|
-
* @param context - The evaluation context with bindings
|
|
1913
|
-
* @returns The evaluation result
|
|
1914
|
-
*/
|
|
1915
|
-
function evaluate(ast, context) {
|
|
1916
|
-
try {
|
|
1917
|
-
const evaluator = new Evaluator(context);
|
|
1918
|
-
const value = evaluator.evaluate(ast);
|
|
1919
|
-
return { value, success: true };
|
|
1920
|
-
}
|
|
1921
|
-
catch (error) {
|
|
1922
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
1923
|
-
return { value: null, success: false, error: message };
|
|
1924
|
-
}
|
|
1925
|
-
}
|
|
1926
1842
|
/**
|
|
1927
1843
|
* Evaluates an AST as a boolean condition.
|
|
1928
1844
|
*
|
|
@@ -2875,7 +2791,7 @@ function getModule() {
|
|
|
2875
2791
|
}
|
|
2876
2792
|
return modulePromise;
|
|
2877
2793
|
}
|
|
2878
|
-
function normalizeConfig$
|
|
2794
|
+
function normalizeConfig$6(config) {
|
|
2879
2795
|
if (!config) {
|
|
2880
2796
|
throw new Error("AdvancedAuthorizationPolicyFactory requires a configuration with a policyDefinition");
|
|
2881
2797
|
}
|
|
@@ -2904,7 +2820,7 @@ function normalizeConfig$5(config) {
|
|
|
2904
2820
|
/**
|
|
2905
2821
|
* Factory metadata for registration.
|
|
2906
2822
|
*/
|
|
2907
|
-
const FACTORY_META$
|
|
2823
|
+
const FACTORY_META$f = {
|
|
2908
2824
|
base: runtime.AUTHORIZATION_POLICY_FACTORY_BASE_TYPE,
|
|
2909
2825
|
key: "AdvancedAuthorizationPolicy",
|
|
2910
2826
|
};
|
|
@@ -2923,7 +2839,7 @@ class AdvancedAuthorizationPolicyFactory extends runtime.AuthorizationPolicyFact
|
|
|
2923
2839
|
* @returns The created authorization policy
|
|
2924
2840
|
*/
|
|
2925
2841
|
async create(config) {
|
|
2926
|
-
const normalized = normalizeConfig$
|
|
2842
|
+
const normalized = normalizeConfig$6(config);
|
|
2927
2843
|
const { AdvancedAuthorizationPolicy } = await getModule();
|
|
2928
2844
|
return new AdvancedAuthorizationPolicy({
|
|
2929
2845
|
policyDefinition: normalized.policyDefinition,
|
|
@@ -2936,10 +2852,569 @@ class AdvancedAuthorizationPolicyFactory extends runtime.AuthorizationPolicyFact
|
|
|
2936
2852
|
var advancedAuthorizationPolicyFactory = /*#__PURE__*/Object.freeze({
|
|
2937
2853
|
__proto__: null,
|
|
2938
2854
|
AdvancedAuthorizationPolicyFactory: AdvancedAuthorizationPolicyFactory,
|
|
2939
|
-
FACTORY_META: FACTORY_META$
|
|
2855
|
+
FACTORY_META: FACTORY_META$f,
|
|
2940
2856
|
default: AdvancedAuthorizationPolicyFactory
|
|
2941
2857
|
});
|
|
2942
2858
|
|
|
2859
|
+
/**
|
|
2860
|
+
* HTTP-based authorization policy source.
|
|
2861
|
+
*
|
|
2862
|
+
* Loads authorization policies from an HTTP endpoint supporting JSON or YAML.
|
|
2863
|
+
* Supports bearer authentication via TokenProvider and HTTP caching via ETag.
|
|
2864
|
+
*
|
|
2865
|
+
* This is a Node.js-only implementation.
|
|
2866
|
+
*
|
|
2867
|
+
* @packageDocumentation
|
|
2868
|
+
*/
|
|
2869
|
+
const logger$i = runtime.getLogger("naylence.fame.security.auth.policy.http_authorization_policy_source");
|
|
2870
|
+
function isPlainObject(value) {
|
|
2871
|
+
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
2872
|
+
}
|
|
2873
|
+
function parseJson(content) {
|
|
2874
|
+
const parsed = JSON.parse(content);
|
|
2875
|
+
if (!isPlainObject(parsed)) {
|
|
2876
|
+
throw new Error("Parsed JSON policy must be an object");
|
|
2877
|
+
}
|
|
2878
|
+
return parsed;
|
|
2879
|
+
}
|
|
2880
|
+
function parseYamlContent(content) {
|
|
2881
|
+
const parsed = yaml.parse(content ?? "");
|
|
2882
|
+
if (parsed == null) {
|
|
2883
|
+
return {};
|
|
2884
|
+
}
|
|
2885
|
+
if (!isPlainObject(parsed)) {
|
|
2886
|
+
throw new Error("Parsed YAML policy must be an object");
|
|
2887
|
+
}
|
|
2888
|
+
return parsed;
|
|
2889
|
+
}
|
|
2890
|
+
/**
|
|
2891
|
+
* Detect whether content is JSON or YAML based on Content-Type header.
|
|
2892
|
+
* Falls back to sniffing the content if Content-Type is not definitive.
|
|
2893
|
+
*/
|
|
2894
|
+
function detectFormat(contentType, content) {
|
|
2895
|
+
if (contentType) {
|
|
2896
|
+
const lower = contentType.toLowerCase();
|
|
2897
|
+
if (lower.includes("application/json") ||
|
|
2898
|
+
lower.includes("text/json")) {
|
|
2899
|
+
return "json";
|
|
2900
|
+
}
|
|
2901
|
+
if (lower.includes("application/yaml") ||
|
|
2902
|
+
lower.includes("application/x-yaml") ||
|
|
2903
|
+
lower.includes("text/yaml") ||
|
|
2904
|
+
lower.includes("text/x-yaml")) {
|
|
2905
|
+
return "yaml";
|
|
2906
|
+
}
|
|
2907
|
+
}
|
|
2908
|
+
// Sniff by first non-whitespace character
|
|
2909
|
+
const trimmed = content.trimStart();
|
|
2910
|
+
if (trimmed.startsWith("{") || trimmed.startsWith("[")) {
|
|
2911
|
+
return "json";
|
|
2912
|
+
}
|
|
2913
|
+
// Default to YAML
|
|
2914
|
+
return "yaml";
|
|
2915
|
+
}
|
|
2916
|
+
/**
|
|
2917
|
+
* Parse Cache-Control header to extract max-age value.
|
|
2918
|
+
*/
|
|
2919
|
+
function parseMaxAge(cacheControl) {
|
|
2920
|
+
if (!cacheControl) {
|
|
2921
|
+
return undefined;
|
|
2922
|
+
}
|
|
2923
|
+
const match = cacheControl.match(/max-age\s*=\s*(\d+)/i);
|
|
2924
|
+
if (match && match[1]) {
|
|
2925
|
+
const seconds = parseInt(match[1], 10);
|
|
2926
|
+
if (Number.isFinite(seconds) && seconds >= 0) {
|
|
2927
|
+
return seconds;
|
|
2928
|
+
}
|
|
2929
|
+
}
|
|
2930
|
+
return undefined;
|
|
2931
|
+
}
|
|
2932
|
+
/**
|
|
2933
|
+
* An authorization policy source that loads policy definitions from an HTTP endpoint.
|
|
2934
|
+
*
|
|
2935
|
+
* Supports JSON and YAML formats, bearer authentication via TokenProvider,
|
|
2936
|
+
* and HTTP caching via ETag and Cache-Control headers.
|
|
2937
|
+
*
|
|
2938
|
+
* This is a Node.js-only implementation that uses fetch.
|
|
2939
|
+
*/
|
|
2940
|
+
class HttpAuthorizationPolicySource {
|
|
2941
|
+
constructor(options) {
|
|
2942
|
+
this.cachedState = null;
|
|
2943
|
+
this.inflightFetch = null;
|
|
2944
|
+
if (!options.url || typeof options.url !== "string") {
|
|
2945
|
+
throw new Error("HttpAuthorizationPolicySource requires a valid URL");
|
|
2946
|
+
}
|
|
2947
|
+
this.url = options.url;
|
|
2948
|
+
this.method = options.method ?? "GET";
|
|
2949
|
+
this.timeoutMs = options.timeoutMs ?? 30000;
|
|
2950
|
+
this.headers = { ...options.headers };
|
|
2951
|
+
this.tokenProvider = options.tokenProvider;
|
|
2952
|
+
this.bearerPrefix = options.bearerPrefix ?? "Bearer ";
|
|
2953
|
+
this.policyFactoryConfig = options.policyFactory;
|
|
2954
|
+
this.cacheTtlMs = options.cacheTtlMs ?? 300000; // 5 minutes default
|
|
2955
|
+
}
|
|
2956
|
+
/**
|
|
2957
|
+
* Loads the authorization policy from the configured HTTP endpoint.
|
|
2958
|
+
*
|
|
2959
|
+
* Returns a cached policy if still fresh (based on TTL or cache headers).
|
|
2960
|
+
* Multiple concurrent calls are de-duplicated (single-flight pattern).
|
|
2961
|
+
*
|
|
2962
|
+
* @returns The loaded authorization policy
|
|
2963
|
+
*/
|
|
2964
|
+
async loadPolicy() {
|
|
2965
|
+
// Return cached policy if still fresh
|
|
2966
|
+
if (this.cachedState && this.isCacheFresh()) {
|
|
2967
|
+
logger$i.debug("returning_cached_policy", {
|
|
2968
|
+
url: this.url,
|
|
2969
|
+
fetchedAt: this.cachedState.metadata.fetchedAt,
|
|
2970
|
+
expiresAt: this.cachedState.metadata.expiresAt,
|
|
2971
|
+
});
|
|
2972
|
+
return this.cachedState.policy;
|
|
2973
|
+
}
|
|
2974
|
+
// De-duplicate concurrent requests
|
|
2975
|
+
if (this.inflightFetch) {
|
|
2976
|
+
return this.inflightFetch;
|
|
2977
|
+
}
|
|
2978
|
+
this.inflightFetch = this.fetchPolicy(false);
|
|
2979
|
+
try {
|
|
2980
|
+
return await this.inflightFetch;
|
|
2981
|
+
}
|
|
2982
|
+
finally {
|
|
2983
|
+
this.inflightFetch = null;
|
|
2984
|
+
}
|
|
2985
|
+
}
|
|
2986
|
+
/**
|
|
2987
|
+
* Forces a reload of the policy from the HTTP endpoint.
|
|
2988
|
+
*
|
|
2989
|
+
* Bypasses cache freshness checks and always fetches from the server.
|
|
2990
|
+
* If the fetch fails, the existing cached policy is preserved and the error is thrown.
|
|
2991
|
+
*
|
|
2992
|
+
* @returns The reloaded authorization policy
|
|
2993
|
+
*/
|
|
2994
|
+
async reloadPolicy() {
|
|
2995
|
+
// Clear inflight to force a new request
|
|
2996
|
+
this.inflightFetch = null;
|
|
2997
|
+
return this.fetchPolicy(true);
|
|
2998
|
+
}
|
|
2999
|
+
/**
|
|
3000
|
+
* Clears the cached policy, forcing a fresh fetch on the next loadPolicy() call.
|
|
3001
|
+
*/
|
|
3002
|
+
clearCache() {
|
|
3003
|
+
this.cachedState = null;
|
|
3004
|
+
this.inflightFetch = null;
|
|
3005
|
+
}
|
|
3006
|
+
/**
|
|
3007
|
+
* Returns metadata about the last successful fetch.
|
|
3008
|
+
*
|
|
3009
|
+
* Useful for verification, monitoring, or debugging.
|
|
3010
|
+
*/
|
|
3011
|
+
getMetadata() {
|
|
3012
|
+
return this.cachedState?.metadata;
|
|
3013
|
+
}
|
|
3014
|
+
/**
|
|
3015
|
+
* Returns the raw policy definition from the last successful fetch.
|
|
3016
|
+
*
|
|
3017
|
+
* Useful for verification or reprocessing.
|
|
3018
|
+
*/
|
|
3019
|
+
getRawDefinition() {
|
|
3020
|
+
return this.cachedState?.rawDefinition;
|
|
3021
|
+
}
|
|
3022
|
+
isCacheFresh() {
|
|
3023
|
+
if (!this.cachedState) {
|
|
3024
|
+
return false;
|
|
3025
|
+
}
|
|
3026
|
+
const now = Date.now();
|
|
3027
|
+
const { expiresAt } = this.cachedState.metadata;
|
|
3028
|
+
if (expiresAt !== undefined) {
|
|
3029
|
+
return now < expiresAt;
|
|
3030
|
+
}
|
|
3031
|
+
// No expiration info, check against default TTL
|
|
3032
|
+
const fetchedAt = this.cachedState.metadata.fetchedAt;
|
|
3033
|
+
return now < fetchedAt + this.cacheTtlMs;
|
|
3034
|
+
}
|
|
3035
|
+
async fetchPolicy(forceRefresh) {
|
|
3036
|
+
logger$i.debug("fetching_policy", {
|
|
3037
|
+
url: this.url,
|
|
3038
|
+
method: this.method,
|
|
3039
|
+
forceRefresh,
|
|
3040
|
+
});
|
|
3041
|
+
const requestHeaders = {
|
|
3042
|
+
Accept: "application/json, application/yaml, text/yaml, */*",
|
|
3043
|
+
...this.headers,
|
|
3044
|
+
};
|
|
3045
|
+
// Add bearer token if token provider is configured
|
|
3046
|
+
if (this.tokenProvider) {
|
|
3047
|
+
try {
|
|
3048
|
+
const token = await this.tokenProvider.getToken();
|
|
3049
|
+
if (token && token.value) {
|
|
3050
|
+
requestHeaders["Authorization"] = `${this.bearerPrefix}${token.value}`;
|
|
3051
|
+
logger$i.debug("added_bearer_token", { url: this.url });
|
|
3052
|
+
}
|
|
3053
|
+
}
|
|
3054
|
+
catch (error) {
|
|
3055
|
+
logger$i.warning("token_provider_failed", {
|
|
3056
|
+
url: this.url,
|
|
3057
|
+
error: error instanceof Error ? error.message : String(error),
|
|
3058
|
+
});
|
|
3059
|
+
// Continue without token - let the server decide if auth is required
|
|
3060
|
+
}
|
|
3061
|
+
}
|
|
3062
|
+
// Add If-None-Match header for conditional request if we have a cached ETag
|
|
3063
|
+
// and this is not a forced refresh
|
|
3064
|
+
if (!forceRefresh && this.cachedState?.metadata.etag) {
|
|
3065
|
+
requestHeaders["If-None-Match"] = this.cachedState.metadata.etag;
|
|
3066
|
+
}
|
|
3067
|
+
const controller = new AbortController();
|
|
3068
|
+
const timeoutId = setTimeout(() => controller.abort(), this.timeoutMs);
|
|
3069
|
+
try {
|
|
3070
|
+
const response = await fetch(this.url, {
|
|
3071
|
+
method: this.method,
|
|
3072
|
+
headers: requestHeaders,
|
|
3073
|
+
signal: controller.signal,
|
|
3074
|
+
});
|
|
3075
|
+
clearTimeout(timeoutId);
|
|
3076
|
+
// Handle 304 Not Modified - return cached policy
|
|
3077
|
+
if (response.status === 304 && this.cachedState) {
|
|
3078
|
+
logger$i.debug("policy_not_modified", {
|
|
3079
|
+
url: this.url,
|
|
3080
|
+
etag: this.cachedState.metadata.etag,
|
|
3081
|
+
});
|
|
3082
|
+
// Update freshness timestamps
|
|
3083
|
+
const now = Date.now();
|
|
3084
|
+
const cacheControl = response.headers.get("Cache-Control");
|
|
3085
|
+
const maxAgeSeconds = parseMaxAge(cacheControl);
|
|
3086
|
+
const expiresAt = maxAgeSeconds !== undefined
|
|
3087
|
+
? now + maxAgeSeconds * 1000
|
|
3088
|
+
: now + this.cacheTtlMs;
|
|
3089
|
+
this.cachedState = {
|
|
3090
|
+
...this.cachedState,
|
|
3091
|
+
metadata: {
|
|
3092
|
+
...this.cachedState.metadata,
|
|
3093
|
+
fetchedAt: now,
|
|
3094
|
+
maxAgeSeconds,
|
|
3095
|
+
expiresAt,
|
|
3096
|
+
},
|
|
3097
|
+
};
|
|
3098
|
+
return this.cachedState.policy;
|
|
3099
|
+
}
|
|
3100
|
+
if (!response.ok) {
|
|
3101
|
+
const errorMessage = `HTTP ${response.status}: ${response.statusText}`;
|
|
3102
|
+
logger$i.error("policy_fetch_failed", {
|
|
3103
|
+
url: this.url,
|
|
3104
|
+
status: response.status,
|
|
3105
|
+
statusText: response.statusText,
|
|
3106
|
+
});
|
|
3107
|
+
// If we have a cached policy, preserve it and throw
|
|
3108
|
+
if (this.cachedState) {
|
|
3109
|
+
throw new Error(`Failed to fetch policy from ${this.url}: ${errorMessage}. ` +
|
|
3110
|
+
"Using last known good policy.");
|
|
3111
|
+
}
|
|
3112
|
+
throw new Error(`Failed to fetch policy from ${this.url}: ${errorMessage}`);
|
|
3113
|
+
}
|
|
3114
|
+
// Parse the response
|
|
3115
|
+
const contentType = response.headers.get("Content-Type");
|
|
3116
|
+
const content = await response.text();
|
|
3117
|
+
const format = detectFormat(contentType, content);
|
|
3118
|
+
let policyDefinition;
|
|
3119
|
+
try {
|
|
3120
|
+
if (format === "json") {
|
|
3121
|
+
policyDefinition = parseJson(content);
|
|
3122
|
+
}
|
|
3123
|
+
else {
|
|
3124
|
+
policyDefinition = parseYamlContent(content);
|
|
3125
|
+
}
|
|
3126
|
+
}
|
|
3127
|
+
catch (parseError) {
|
|
3128
|
+
const message = parseError instanceof Error
|
|
3129
|
+
? parseError.message
|
|
3130
|
+
: String(parseError);
|
|
3131
|
+
logger$i.error("policy_parse_failed", {
|
|
3132
|
+
url: this.url,
|
|
3133
|
+
format,
|
|
3134
|
+
error: message,
|
|
3135
|
+
});
|
|
3136
|
+
// Preserve cached policy on parse failure
|
|
3137
|
+
if (this.cachedState) {
|
|
3138
|
+
throw new Error(`Failed to parse policy from ${this.url}: ${message}. ` +
|
|
3139
|
+
"Using last known good policy.");
|
|
3140
|
+
}
|
|
3141
|
+
throw new Error(`Failed to parse policy from ${this.url}: ${message}`);
|
|
3142
|
+
}
|
|
3143
|
+
logger$i.debug("parsed_policy_definition", {
|
|
3144
|
+
url: this.url,
|
|
3145
|
+
format,
|
|
3146
|
+
hasType: "type" in policyDefinition,
|
|
3147
|
+
});
|
|
3148
|
+
// Build the policy using the factory
|
|
3149
|
+
const policy = await this.buildPolicy(policyDefinition);
|
|
3150
|
+
// Update cache
|
|
3151
|
+
const now = Date.now();
|
|
3152
|
+
const etag = response.headers.get("ETag") ?? undefined;
|
|
3153
|
+
const cacheControl = response.headers.get("Cache-Control");
|
|
3154
|
+
const maxAgeSeconds = parseMaxAge(cacheControl);
|
|
3155
|
+
const expiresAt = maxAgeSeconds !== undefined
|
|
3156
|
+
? now + maxAgeSeconds * 1000
|
|
3157
|
+
: now + this.cacheTtlMs;
|
|
3158
|
+
this.cachedState = {
|
|
3159
|
+
policy,
|
|
3160
|
+
rawDefinition: policyDefinition,
|
|
3161
|
+
metadata: {
|
|
3162
|
+
url: this.url,
|
|
3163
|
+
status: response.status,
|
|
3164
|
+
etag,
|
|
3165
|
+
fetchedAt: now,
|
|
3166
|
+
maxAgeSeconds,
|
|
3167
|
+
expiresAt,
|
|
3168
|
+
},
|
|
3169
|
+
};
|
|
3170
|
+
logger$i.info("loaded_policy_from_http", {
|
|
3171
|
+
url: this.url,
|
|
3172
|
+
status: response.status,
|
|
3173
|
+
format,
|
|
3174
|
+
etag,
|
|
3175
|
+
maxAgeSeconds,
|
|
3176
|
+
});
|
|
3177
|
+
return policy;
|
|
3178
|
+
}
|
|
3179
|
+
catch (error) {
|
|
3180
|
+
clearTimeout(timeoutId);
|
|
3181
|
+
if (error instanceof Error && error.name === "AbortError") {
|
|
3182
|
+
const timeoutError = new Error(`Request to ${this.url} timed out after ${this.timeoutMs}ms`);
|
|
3183
|
+
logger$i.error("policy_fetch_timeout", {
|
|
3184
|
+
url: this.url,
|
|
3185
|
+
timeoutMs: this.timeoutMs,
|
|
3186
|
+
});
|
|
3187
|
+
// Preserve cached policy on timeout
|
|
3188
|
+
if (this.cachedState) {
|
|
3189
|
+
throw timeoutError;
|
|
3190
|
+
}
|
|
3191
|
+
throw timeoutError;
|
|
3192
|
+
}
|
|
3193
|
+
throw error;
|
|
3194
|
+
}
|
|
3195
|
+
}
|
|
3196
|
+
async buildPolicy(policyDefinition) {
|
|
3197
|
+
// Determine the factory configuration to use
|
|
3198
|
+
const factoryConfig = this.policyFactoryConfig ?? policyDefinition;
|
|
3199
|
+
// Ensure we have a type field for the factory
|
|
3200
|
+
if (!("type" in factoryConfig) || typeof factoryConfig.type !== "string") {
|
|
3201
|
+
logger$i.warning("policy_type_missing_defaulting_to_basic", {
|
|
3202
|
+
url: this.url,
|
|
3203
|
+
});
|
|
3204
|
+
factoryConfig.type = "BasicAuthorizationPolicy";
|
|
3205
|
+
}
|
|
3206
|
+
// Build the factory config with the policy definition
|
|
3207
|
+
// The response content IS the policy definition, so we extract the type
|
|
3208
|
+
// and wrap the remaining content as the policyDefinition
|
|
3209
|
+
const { type: definitionType, ...restOfDefinition } = policyDefinition;
|
|
3210
|
+
const resolvedType = typeof definitionType === "string" && definitionType.trim().length > 0
|
|
3211
|
+
? definitionType
|
|
3212
|
+
: factoryConfig.type;
|
|
3213
|
+
const mergedConfig = this.policyFactoryConfig != null
|
|
3214
|
+
? { ...this.policyFactoryConfig, policyDefinition }
|
|
3215
|
+
: { type: resolvedType, policyDefinition: restOfDefinition };
|
|
3216
|
+
const policy = await runtime.AuthorizationPolicyFactory.createAuthorizationPolicy(mergedConfig);
|
|
3217
|
+
if (!policy) {
|
|
3218
|
+
throw new Error(`Failed to create authorization policy from ${this.url}`);
|
|
3219
|
+
}
|
|
3220
|
+
return policy;
|
|
3221
|
+
}
|
|
3222
|
+
}
|
|
3223
|
+
|
|
3224
|
+
var httpAuthorizationPolicySource = /*#__PURE__*/Object.freeze({
|
|
3225
|
+
__proto__: null,
|
|
3226
|
+
HttpAuthorizationPolicySource: HttpAuthorizationPolicySource
|
|
3227
|
+
});
|
|
3228
|
+
|
|
3229
|
+
/**
|
|
3230
|
+
* Factory for creating HttpAuthorizationPolicySource instances.
|
|
3231
|
+
*
|
|
3232
|
+
* @packageDocumentation
|
|
3233
|
+
*/
|
|
3234
|
+
let httpModulePromise = null;
|
|
3235
|
+
async function getHttpModule() {
|
|
3236
|
+
if (!httpModulePromise) {
|
|
3237
|
+
httpModulePromise = Promise.resolve().then(function () { return httpAuthorizationPolicySource; });
|
|
3238
|
+
}
|
|
3239
|
+
return httpModulePromise;
|
|
3240
|
+
}
|
|
3241
|
+
function normalizeConfig$5(config) {
|
|
3242
|
+
if (!config) {
|
|
3243
|
+
throw new Error("HttpAuthorizationPolicySourceFactory requires a configuration with a url");
|
|
3244
|
+
}
|
|
3245
|
+
const candidate = config;
|
|
3246
|
+
const url = candidate.url;
|
|
3247
|
+
if (typeof url !== "string" || url.trim().length === 0) {
|
|
3248
|
+
throw new Error("HttpAuthorizationPolicySourceConfig requires a non-empty url");
|
|
3249
|
+
}
|
|
3250
|
+
// Support both camelCase and snake_case
|
|
3251
|
+
const method = candidate.method ?? "GET";
|
|
3252
|
+
if (!["GET", "POST", "PUT"].includes(method)) {
|
|
3253
|
+
throw new Error(`Invalid method "${String(method)}". Must be "GET", "POST", or "PUT"`);
|
|
3254
|
+
}
|
|
3255
|
+
const timeoutMs = candidate.timeout_ms ??
|
|
3256
|
+
candidate.timeoutMs ??
|
|
3257
|
+
30000;
|
|
3258
|
+
if (typeof timeoutMs !== "number" || !Number.isFinite(timeoutMs) || timeoutMs <= 0) {
|
|
3259
|
+
throw new Error("timeout_ms must be a positive number");
|
|
3260
|
+
}
|
|
3261
|
+
const headers = candidate.headers;
|
|
3262
|
+
if (headers !== undefined && typeof headers !== "object") {
|
|
3263
|
+
throw new Error("headers must be an object");
|
|
3264
|
+
}
|
|
3265
|
+
const tokenProviderConfig = candidate.token_provider ??
|
|
3266
|
+
candidate.tokenProvider;
|
|
3267
|
+
const bearerPrefix = candidate.bearer_prefix ??
|
|
3268
|
+
candidate.bearerPrefix ??
|
|
3269
|
+
"Bearer ";
|
|
3270
|
+
const policyFactory = candidate.policy_factory ??
|
|
3271
|
+
candidate.policyFactory;
|
|
3272
|
+
const cacheTtlMs = candidate.cache_ttl_ms ??
|
|
3273
|
+
candidate.cacheTtlMs ??
|
|
3274
|
+
300000;
|
|
3275
|
+
if (typeof cacheTtlMs !== "number" || !Number.isFinite(cacheTtlMs) || cacheTtlMs < 0) {
|
|
3276
|
+
throw new Error("cache_ttl_ms must be a non-negative number");
|
|
3277
|
+
}
|
|
3278
|
+
return {
|
|
3279
|
+
url: url.trim(),
|
|
3280
|
+
method,
|
|
3281
|
+
timeoutMs,
|
|
3282
|
+
headers,
|
|
3283
|
+
tokenProviderConfig,
|
|
3284
|
+
bearerPrefix,
|
|
3285
|
+
policyFactory,
|
|
3286
|
+
cacheTtlMs,
|
|
3287
|
+
};
|
|
3288
|
+
}
|
|
3289
|
+
/**
|
|
3290
|
+
* Factory metadata for registration.
|
|
3291
|
+
*/
|
|
3292
|
+
const FACTORY_META$e = {
|
|
3293
|
+
base: runtime.AUTHORIZATION_POLICY_SOURCE_FACTORY_BASE_TYPE,
|
|
3294
|
+
key: "HttpAuthorizationPolicySource",
|
|
3295
|
+
};
|
|
3296
|
+
/**
|
|
3297
|
+
* Factory for creating HttpAuthorizationPolicySource instances.
|
|
3298
|
+
*
|
|
3299
|
+
* This factory uses lazy loading to avoid pulling in Node.js-specific
|
|
3300
|
+
* code (fetch operations) in browser environments where it may not work.
|
|
3301
|
+
*/
|
|
3302
|
+
class HttpAuthorizationPolicySourceFactory extends runtime.AuthorizationPolicySourceFactory {
|
|
3303
|
+
constructor() {
|
|
3304
|
+
super(...arguments);
|
|
3305
|
+
this.type = "HttpAuthorizationPolicySource";
|
|
3306
|
+
}
|
|
3307
|
+
/**
|
|
3308
|
+
* Creates an HttpAuthorizationPolicySource from the given configuration.
|
|
3309
|
+
*
|
|
3310
|
+
* @param config - Configuration specifying the policy URL and options
|
|
3311
|
+
* @returns The created policy source
|
|
3312
|
+
*/
|
|
3313
|
+
async create(config) {
|
|
3314
|
+
const normalized = normalizeConfig$5(config);
|
|
3315
|
+
// Create token provider if configured
|
|
3316
|
+
let tokenProvider;
|
|
3317
|
+
if (normalized.tokenProviderConfig) {
|
|
3318
|
+
tokenProvider = await runtime.TokenProviderFactory.createTokenProvider(normalized.tokenProviderConfig);
|
|
3319
|
+
}
|
|
3320
|
+
const { HttpAuthorizationPolicySource } = await getHttpModule();
|
|
3321
|
+
const options = {
|
|
3322
|
+
url: normalized.url,
|
|
3323
|
+
method: normalized.method,
|
|
3324
|
+
timeoutMs: normalized.timeoutMs,
|
|
3325
|
+
headers: normalized.headers,
|
|
3326
|
+
tokenProvider,
|
|
3327
|
+
bearerPrefix: normalized.bearerPrefix,
|
|
3328
|
+
policyFactory: normalized.policyFactory,
|
|
3329
|
+
cacheTtlMs: normalized.cacheTtlMs,
|
|
3330
|
+
};
|
|
3331
|
+
return new HttpAuthorizationPolicySource(options);
|
|
3332
|
+
}
|
|
3333
|
+
}
|
|
3334
|
+
|
|
3335
|
+
var httpAuthorizationPolicySourceFactory = /*#__PURE__*/Object.freeze({
|
|
3336
|
+
__proto__: null,
|
|
3337
|
+
FACTORY_META: FACTORY_META$e,
|
|
3338
|
+
HttpAuthorizationPolicySourceFactory: HttpAuthorizationPolicySourceFactory,
|
|
3339
|
+
default: HttpAuthorizationPolicySourceFactory
|
|
3340
|
+
});
|
|
3341
|
+
|
|
3342
|
+
/**
|
|
3343
|
+
* HTTP Policy Authorization Profile
|
|
3344
|
+
*
|
|
3345
|
+
* Provides the 'policy-http' authorization profile for loading policies over HTTP(S).
|
|
3346
|
+
* This profile is similar to 'policy-localfile' from the runtime package but uses
|
|
3347
|
+
* the HttpAuthorizationPolicySource instead of LocalFileAuthorizationPolicySource.
|
|
3348
|
+
*/
|
|
3349
|
+
// Environment variable names for HTTP policy source
|
|
3350
|
+
const ENV_VAR_AUTH_POLICY_URL = "FAME_AUTH_POLICY_URL";
|
|
3351
|
+
const ENV_VAR_AUTH_POLICY_TIMEOUT_MS = "FAME_AUTH_POLICY_TIMEOUT_MS";
|
|
3352
|
+
const ENV_VAR_AUTH_POLICY_CACHE_TTL_MS = "FAME_AUTH_POLICY_CACHE_TTL_MS";
|
|
3353
|
+
const ENV_VAR_AUTH_POLICY_TOKEN_URL = "FAME_AUTH_POLICY_TOKEN_URL";
|
|
3354
|
+
const ENV_VAR_AUTH_POLICY_CLIENT_ID = "FAME_AUTH_POLICY_CLIENT_ID";
|
|
3355
|
+
const ENV_VAR_AUTH_POLICY_CLIENT_SECRET = "FAME_AUTH_POLICY_CLIENT_SECRET";
|
|
3356
|
+
const ENV_VAR_AUTH_POLICY_AUDIENCE = "FAME_AUTH_POLICY_AUDIENCE";
|
|
3357
|
+
// Legacy environment variable for backwards compatibility
|
|
3358
|
+
const ENV_VAR_AUTH_POLICY_BEARER_TOKEN = "FAME_AUTH_POLICY_BEARER_TOKEN";
|
|
3359
|
+
// Profile name constant
|
|
3360
|
+
const PROFILE_NAME_POLICY_HTTP = "policy-http";
|
|
3361
|
+
// Re-use JWT verifier env vars from runtime
|
|
3362
|
+
const ENV_VAR_JWKS_URL = "FAME_JWKS_URL";
|
|
3363
|
+
const ENV_VAR_JWT_TRUSTED_ISSUER = "FAME_JWT_TRUSTED_ISSUER";
|
|
3364
|
+
/**
|
|
3365
|
+
* Default token verifier configuration using JWKS.
|
|
3366
|
+
*/
|
|
3367
|
+
const DEFAULT_VERIFIER_CONFIG = {
|
|
3368
|
+
type: "JWKSJWTTokenVerifier",
|
|
3369
|
+
jwks_url: factory.Expressions.env(ENV_VAR_JWKS_URL),
|
|
3370
|
+
issuer: factory.Expressions.env(ENV_VAR_JWT_TRUSTED_ISSUER),
|
|
3371
|
+
};
|
|
3372
|
+
/**
|
|
3373
|
+
* Creates OAuth2 token provider configuration for HTTP policy source.
|
|
3374
|
+
*
|
|
3375
|
+
* Uses environment variables for OAuth2 client credentials flow.
|
|
3376
|
+
*/
|
|
3377
|
+
function createOAuth2TokenProviderConfig() {
|
|
3378
|
+
const tokenUrl = factory.Expressions.env(ENV_VAR_AUTH_POLICY_TOKEN_URL);
|
|
3379
|
+
const clientId = factory.Expressions.env(ENV_VAR_AUTH_POLICY_CLIENT_ID);
|
|
3380
|
+
const clientSecret = factory.Expressions.env(ENV_VAR_AUTH_POLICY_CLIENT_SECRET);
|
|
3381
|
+
const audience = factory.Expressions.env(ENV_VAR_AUTH_POLICY_AUDIENCE);
|
|
3382
|
+
return {
|
|
3383
|
+
type: "OAuth2ClientCredentialsTokenProvider",
|
|
3384
|
+
token_url: tokenUrl,
|
|
3385
|
+
tokenUrl,
|
|
3386
|
+
client_id: clientId,
|
|
3387
|
+
clientId,
|
|
3388
|
+
client_secret: clientSecret,
|
|
3389
|
+
clientSecret,
|
|
3390
|
+
scopes: ["policy.read"],
|
|
3391
|
+
audience,
|
|
3392
|
+
};
|
|
3393
|
+
}
|
|
3394
|
+
/**
|
|
3395
|
+
* Default HTTP policy source configuration.
|
|
3396
|
+
*
|
|
3397
|
+
* Uses environment variables for URL, timeout, and OAuth2 client credentials.
|
|
3398
|
+
*/
|
|
3399
|
+
const DEFAULT_HTTP_POLICY_SOURCE = {
|
|
3400
|
+
type: "HttpAuthorizationPolicySource",
|
|
3401
|
+
url: factory.Expressions.env(ENV_VAR_AUTH_POLICY_URL),
|
|
3402
|
+
timeout_ms: factory.Expressions.env(ENV_VAR_AUTH_POLICY_TIMEOUT_MS, "30000"),
|
|
3403
|
+
cache_ttl_ms: factory.Expressions.env(ENV_VAR_AUTH_POLICY_CACHE_TTL_MS, "300000"),
|
|
3404
|
+
// OAuth2 client credentials token provider
|
|
3405
|
+
token_provider: createOAuth2TokenProviderConfig(),
|
|
3406
|
+
};
|
|
3407
|
+
const POLICY_HTTP_PROFILE = {
|
|
3408
|
+
type: "PolicyAuthorizer",
|
|
3409
|
+
verifier: DEFAULT_VERIFIER_CONFIG,
|
|
3410
|
+
policy_source: DEFAULT_HTTP_POLICY_SOURCE,
|
|
3411
|
+
};
|
|
3412
|
+
// Register the policy-http profile
|
|
3413
|
+
runtime.registerProfile(runtime.AUTHORIZER_FACTORY_BASE_TYPE, PROFILE_NAME_POLICY_HTTP, POLICY_HTTP_PROFILE, {
|
|
3414
|
+
source: "advanced-security:policy-http-authorization-profile",
|
|
3415
|
+
allowOverride: true,
|
|
3416
|
+
});
|
|
3417
|
+
|
|
2943
3418
|
const logger$h = runtime.getLogger("naylence.fame.security.cert.util");
|
|
2944
3419
|
const CACHE_LIMIT = 512;
|
|
2945
3420
|
const OID_ED25519 = "1.3.101.112";
|
|
@@ -8988,6 +9463,7 @@ var advancedWelcomeServiceFactory = /*#__PURE__*/Object.freeze({
|
|
|
8988
9463
|
*/
|
|
8989
9464
|
const MODULES = [
|
|
8990
9465
|
"./security/auth/policy/advanced-authorization-policy-factory.js",
|
|
9466
|
+
"./security/auth/policy/http-authorization-policy-source-factory.js",
|
|
8991
9467
|
"./security/cert/default-ca-service-factory.js",
|
|
8992
9468
|
"./security/cert/default-certificate-manager-factory.js",
|
|
8993
9469
|
"./security/cert/trust-store/browser-trust-store-provider-factory.js",
|
|
@@ -9005,6 +9481,7 @@ const MODULES = [
|
|
|
9005
9481
|
];
|
|
9006
9482
|
const MODULE_LOADERS = {
|
|
9007
9483
|
"./security/auth/policy/advanced-authorization-policy-factory.js": () => Promise.resolve().then(function () { return advancedAuthorizationPolicyFactory; }),
|
|
9484
|
+
"./security/auth/policy/http-authorization-policy-source-factory.js": () => Promise.resolve().then(function () { return httpAuthorizationPolicySourceFactory; }),
|
|
9008
9485
|
"./security/cert/default-ca-service-factory.js": () => Promise.resolve().then(function () { return defaultCaServiceFactory; }),
|
|
9009
9486
|
"./security/cert/default-certificate-manager-factory.js": () => Promise.resolve().then(function () { return defaultCertificateManagerFactory; }),
|
|
9010
9487
|
"./security/cert/trust-store/browser-trust-store-provider-factory.js": () => Promise.resolve().then(function () { return browserTrustStoreProviderFactory; }),
|
|
@@ -9094,6 +9571,7 @@ const SECURITY_PREFIX = "./security/";
|
|
|
9094
9571
|
const SECURITY_MODULES = MODULES.filter((spec) => spec.startsWith(SECURITY_PREFIX));
|
|
9095
9572
|
const EXTRA_MODULES = MODULES.filter((spec) => !spec.startsWith(SECURITY_PREFIX));
|
|
9096
9573
|
const NODE_ONLY_MODULES = new Set([
|
|
9574
|
+
"./security/auth/policy/http-authorization-policy-source-factory.js",
|
|
9097
9575
|
"./security/cert/default-ca-service-factory.js",
|
|
9098
9576
|
"./security/cert/trust-store/node-trust-store-provider-factory.js",
|
|
9099
9577
|
]);
|
|
@@ -12847,7 +13325,7 @@ var plugin = /*#__PURE__*/Object.freeze({
|
|
|
12847
13325
|
registerAdvancedSecurityPluginFactories: registerAdvancedSecurityPluginFactories
|
|
12848
13326
|
});
|
|
12849
13327
|
|
|
12850
|
-
exports.ADVANCED_AUTHORIZATION_POLICY_FACTORY_META = FACTORY_META$
|
|
13328
|
+
exports.ADVANCED_AUTHORIZATION_POLICY_FACTORY_META = FACTORY_META$f;
|
|
12851
13329
|
exports.ADVANCED_EDDSA_ENVELOPE_SIGNER_FACTORY_META = FACTORY_META$9;
|
|
12852
13330
|
exports.ADVANCED_EDDSA_ENVELOPE_VERIFIER_FACTORY_META = FACTORY_META$8;
|
|
12853
13331
|
exports.ADVANCED_WELCOME_FACTORY_META = FACTORY_META$4;
|
|
@@ -12864,76 +13342,51 @@ exports.AdvancedEdDSAEnvelopeSignerFactory = AdvancedEdDSAEnvelopeSignerFactory;
|
|
|
12864
13342
|
exports.AdvancedEdDSAEnvelopeVerifierFactory = AdvancedEdDSAEnvelopeVerifierFactory;
|
|
12865
13343
|
exports.AdvancedWelcomeService = AdvancedWelcomeService;
|
|
12866
13344
|
exports.AdvancedWelcomeServiceFactory = AdvancedWelcomeServiceFactory;
|
|
12867
|
-
exports.BUILTIN_FUNCTIONS = BUILTIN_FUNCTIONS;
|
|
12868
|
-
exports.BuiltinError = BuiltinError;
|
|
12869
13345
|
exports.CAServiceClient = CAServiceClient;
|
|
12870
13346
|
exports.CompositeEncryptionManager = CompositeEncryptionManager;
|
|
12871
13347
|
exports.CompositeEncryptionManagerFactory = CompositeEncryptionManagerFactory;
|
|
12872
|
-
exports.DEFAULT_EXPRESSION_LIMITS = DEFAULT_EXPRESSION_LIMITS;
|
|
12873
13348
|
exports.DEFAULT_SECURE_CHANNEL_MANAGER_FACTORY_META = FACTORY_META$b;
|
|
12874
13349
|
exports.DEFAULT_STICKINESS_SECURITY_LEVEL = DEFAULT_STICKINESS_SECURITY_LEVEL;
|
|
12875
13350
|
exports.DefaultSecureChannelManager = DefaultSecureChannelManager;
|
|
12876
13351
|
exports.DefaultSecureChannelManagerFactory = DefaultSecureChannelManagerFactory;
|
|
13352
|
+
exports.ENV_VAR_AUTH_POLICY_BEARER_TOKEN = ENV_VAR_AUTH_POLICY_BEARER_TOKEN;
|
|
13353
|
+
exports.ENV_VAR_AUTH_POLICY_CACHE_TTL_MS = ENV_VAR_AUTH_POLICY_CACHE_TTL_MS;
|
|
13354
|
+
exports.ENV_VAR_AUTH_POLICY_TIMEOUT_MS = ENV_VAR_AUTH_POLICY_TIMEOUT_MS;
|
|
13355
|
+
exports.ENV_VAR_AUTH_POLICY_URL = ENV_VAR_AUTH_POLICY_URL;
|
|
12877
13356
|
exports.ENV_VAR_FAME_CA_SERVICE_URL = ENV_VAR_FAME_CA_SERVICE_URL;
|
|
12878
13357
|
exports.EdDSAEnvelopeVerifier = EdDSAEnvelopeVerifier;
|
|
12879
|
-
exports.EvaluationError = EvaluationError;
|
|
12880
|
-
exports.Evaluator = Evaluator;
|
|
12881
|
-
exports.ExpressionError = ExpressionError;
|
|
12882
13358
|
exports.GRANT_PURPOSE_CA_SIGN = GRANT_PURPOSE_CA_SIGN;
|
|
12883
|
-
exports.
|
|
13359
|
+
exports.HTTP_AUTHORIZATION_POLICY_SOURCE_FACTORY_META = FACTORY_META$e;
|
|
13360
|
+
exports.HttpAuthorizationPolicySource = HttpAuthorizationPolicySource;
|
|
13361
|
+
exports.HttpAuthorizationPolicySourceFactory = HttpAuthorizationPolicySourceFactory;
|
|
12884
13362
|
exports.NoAFTSigner = NoAFTSigner;
|
|
12885
|
-
exports.
|
|
12886
|
-
exports.Parser = Parser;
|
|
13363
|
+
exports.PROFILE_NAME_POLICY_HTTP = PROFILE_NAME_POLICY_HTTP;
|
|
12887
13364
|
exports.SidOnlyAFTVerifier = SidOnlyAFTVerifier;
|
|
12888
13365
|
exports.SignedAFTSigner = SignedAFTSigner;
|
|
12889
13366
|
exports.SignedOptionalAFTVerifier = SignedOptionalAFTVerifier;
|
|
12890
13367
|
exports.StrictAFTVerifier = StrictAFTVerifier;
|
|
12891
|
-
exports.Tokenizer = Tokenizer;
|
|
12892
|
-
exports.TokenizerError = TokenizerError;
|
|
12893
|
-
exports.TypeError = TypeError;
|
|
12894
13368
|
exports.UnsignedAFTSigner = UnsignedAFTSigner;
|
|
12895
13369
|
exports.VERSION = VERSION;
|
|
12896
13370
|
exports.X5CKeyManager = X5CKeyManager;
|
|
12897
13371
|
exports.X5CKeyManagerFactory = X5CKeyManagerFactory;
|
|
12898
13372
|
exports.X5C_KEY_MANAGER_FACTORY_META = FACTORY_META$7;
|
|
12899
13373
|
exports.__advancedSecurityPluginLoader = __advancedSecurityPluginLoader;
|
|
12900
|
-
exports.astToString = astToString;
|
|
12901
13374
|
exports.base64UrlDecode = base64UrlDecode;
|
|
12902
13375
|
exports.base64UrlEncode = base64UrlEncode;
|
|
12903
|
-
exports.calculateAstDepth = calculateAstDepth;
|
|
12904
|
-
exports.callBuiltin = callBuiltin;
|
|
12905
13376
|
exports.channelEncryption = index;
|
|
12906
|
-
exports.checkArrayLength = checkArrayLength;
|
|
12907
|
-
exports.checkAstDepth = checkAstDepth;
|
|
12908
|
-
exports.checkAstNodeCount = checkAstNodeCount;
|
|
12909
|
-
exports.checkExpressionLength = checkExpressionLength;
|
|
12910
|
-
exports.checkFunctionArgCount = checkFunctionArgCount;
|
|
12911
|
-
exports.checkGlobPatternLength = checkGlobPatternLength;
|
|
12912
|
-
exports.checkRegexPatternLength = checkRegexPatternLength;
|
|
12913
|
-
exports.countAstNodes = countAstNodes;
|
|
12914
13377
|
exports.createAftHelper = createAftHelper;
|
|
12915
13378
|
exports.createAftPayload = createAftPayload;
|
|
12916
13379
|
exports.createAftReplicaStickinessManager = createAftReplicaStickinessManager;
|
|
12917
13380
|
exports.createAftSigner = createAftSigner;
|
|
12918
13381
|
exports.createAftVerifier = createAftVerifier;
|
|
12919
|
-
exports.createAuthFunctionRegistry = createAuthFunctionRegistry;
|
|
12920
13382
|
exports.createEd25519Csr = createEd25519Csr;
|
|
12921
|
-
exports.createSecurityBindings = createSecurityBindings;
|
|
12922
|
-
exports.evaluate = evaluate;
|
|
12923
|
-
exports.evaluateAsBoolean = evaluateAsBoolean;
|
|
12924
13383
|
exports.extractCertificateInfo = extractCertificateInfo;
|
|
12925
13384
|
exports.formatCertificateInfo = formatCertificateInfo;
|
|
12926
|
-
exports.getTypeName = getTypeName;
|
|
12927
|
-
exports.isBuiltinFunction = isBuiltinFunction;
|
|
12928
|
-
exports.normalizeEncryptionLevelFromAlg = normalizeEncryptionLevelFromAlg;
|
|
12929
|
-
exports.normalizeJsValue = normalizeJsValue;
|
|
12930
13385
|
exports.normalizeStickinessMode = normalizeStickinessMode;
|
|
12931
|
-
exports.parse = parse;
|
|
12932
13386
|
exports.publicKeyFromX5c = publicKeyFromX5c;
|
|
12933
13387
|
exports.registerAdvancedSecurityFactories = registerAdvancedSecurityFactories;
|
|
12934
13388
|
exports.sealedEncryption = index$1;
|
|
12935
13389
|
exports.serializeAftClaims = serializeAftClaims;
|
|
12936
13390
|
exports.serializeAftHeader = serializeAftHeader;
|
|
12937
|
-
exports.tokenize = tokenize;
|
|
12938
13391
|
exports.utf8Decode = utf8Decode;
|
|
12939
13392
|
exports.validateJwkX5cCertificate = validateJwkX5cCertificate;
|