@naylence/advanced-security 0.4.4 → 0.4.5
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 +201 -18
- package/dist/browser/index.mjs +200 -17
- package/dist/cjs/naylence/fame/expr/builtins.js +1 -1
- package/dist/cjs/naylence/fame/expr/builtins.js.map +1 -1
- package/dist/cjs/naylence/fame/security/auth/policy/advanced-authorization-policy.js +32 -13
- package/dist/cjs/naylence/fame/security/auth/policy/advanced-authorization-policy.js.map +1 -1
- package/dist/cjs/naylence/fame/security/auth/policy/expr-builtins.js +166 -2
- package/dist/cjs/naylence/fame/security/auth/policy/expr-builtins.js.map +1 -1
- package/dist/cjs/naylence/fame/security/auth/policy/index.js +1 -1
- package/dist/cjs/naylence/fame/security/auth/policy/index.js.map +1 -1
- package/dist/cjs/version.js +2 -2
- package/dist/esm/naylence/fame/expr/builtins.js +1 -1
- package/dist/esm/naylence/fame/expr/builtins.js.map +1 -1
- package/dist/esm/naylence/fame/security/auth/policy/advanced-authorization-policy.js +32 -13
- package/dist/esm/naylence/fame/security/auth/policy/advanced-authorization-policy.js.map +1 -1
- package/dist/esm/naylence/fame/security/auth/policy/expr-builtins.js +166 -2
- package/dist/esm/naylence/fame/security/auth/policy/expr-builtins.js.map +1 -1
- package/dist/esm/naylence/fame/security/auth/policy/index.js +1 -1
- package/dist/esm/naylence/fame/security/auth/policy/index.js.map +1 -1
- package/dist/esm/version.js +2 -2
- package/dist/node/index.cjs +203 -18
- package/dist/node/index.mjs +201 -18
- package/dist/node/node.cjs +203 -18
- package/dist/node/node.mjs +201 -18
- package/dist/types/naylence/fame/security/auth/policy/advanced-authorization-policy.d.ts.map +1 -1
- package/dist/types/naylence/fame/security/auth/policy/expr-builtins.d.ts +71 -1
- package/dist/types/naylence/fame/security/auth/policy/expr-builtins.d.ts.map +1 -1
- package/dist/types/naylence/fame/security/auth/policy/index.d.ts +1 -1
- package/dist/types/naylence/fame/security/auth/policy/index.d.ts.map +1 -1
- package/dist/types/version.d.ts +1 -1
- package/package.json +1 -1
package/dist/node/node.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ExtensionManager, Expressions, Registry, AbstractResourceFactory, createResource, createDefaultResource } from '@naylence/factory';
|
|
2
2
|
import { getLogger, ENCRYPTION_MANAGER_FACTORY_BASE_TYPE, 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 as TrustStoreProviderFactory$1, 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, formatTimestamp, AnsiColor, jsonDumps, validateHostLogicals, HTTP_CONNECTION_GRANT_TYPE, WELCOME_SERVICE_FACTORY_BASE_TYPE, WelcomeServiceFactory, NodePlacementStrategyFactory, TransportProvisionerFactory, TokenIssuerFactory, AuthorizerFactory, AuthInjectionStrategyFactory, CERTIFICATE_MANAGER_FACTORY_BASE_TYPE, CertificateManagerFactory, TRUST_STORE_PROVIDER_FACTORY_BASE_TYPE as TRUST_STORE_PROVIDER_FACTORY_BASE_TYPE$1, validateHostLogical } from '@naylence/runtime';
|
|
3
|
-
import { sha256 } from '@noble/hashes/
|
|
3
|
+
import { sha256 } from '@noble/hashes/sha2';
|
|
4
4
|
import { generateFingerprintSync, localDeliveryContext, createFameEnvelope, FameAddress, generateId, formatAddress, SigningMaterial, DeliveryOriginType as DeliveryOriginType$1 } from '@naylence/core';
|
|
5
5
|
import { AsnConvert, OctetString } from '@peculiar/asn1-schema';
|
|
6
6
|
import { Certificate, id_ce_subjectAltName, SubjectAlternativeName, id_ce_nameConstraints, NameConstraints, Name, RelativeDistinguishedName, AttributeTypeAndValue, AttributeValue, SubjectPublicKeyInfo, GeneralName, Extensions, Extension, Attribute, AlgorithmIdentifier, TBSCertificate, Validity, Version, BasicConstraints, id_ce_basicConstraints, KeyUsageFlags, KeyUsage, id_ce_keyUsage, SubjectKeyIdentifier, id_ce_subjectKeyIdentifier, AuthorityKeyIdentifier, KeyIdentifier, id_ce_authorityKeyIdentifier, GeneralSubtrees, GeneralSubtree, ExtendedKeyUsage, id_kp_clientAuth, id_kp_serverAuth, id_ce_extKeyUsage } from '@peculiar/asn1-x509';
|
|
@@ -573,12 +573,12 @@ async function registerAdvancedSecurityFactories(registrar = Registry, options)
|
|
|
573
573
|
}
|
|
574
574
|
|
|
575
575
|
// This file is auto-generated during build - do not edit manually
|
|
576
|
-
// Generated from package.json version: 0.4.
|
|
576
|
+
// Generated from package.json version: 0.4.5
|
|
577
577
|
/**
|
|
578
578
|
* The package version, injected at build time.
|
|
579
579
|
* @internal
|
|
580
580
|
*/
|
|
581
|
-
const VERSION = '0.4.
|
|
581
|
+
const VERSION = '0.4.5';
|
|
582
582
|
|
|
583
583
|
async function registerAdvancedSecurityPluginFactories(registrar = Registry) {
|
|
584
584
|
await registerAdvancedSecurityFactories(registrar, { includeExtras: true });
|
|
@@ -2557,8 +2557,86 @@ function evaluateAsBoolean(ast, context) {
|
|
|
2557
2557
|
* Null handling semantics:
|
|
2558
2558
|
* - Scope predicate builtins (has_scope, has_any_scope, has_all_scopes)
|
|
2559
2559
|
* return `false` when passed `null` for required args.
|
|
2560
|
+
* - Security predicate builtins (is_signed, is_encrypted, is_encrypted_at_least)
|
|
2561
|
+
* return `false` when the envelope lacks the required security posture.
|
|
2560
2562
|
* - Wrong non-null types still raise BuiltinError to surface real bugs.
|
|
2561
2563
|
*/
|
|
2564
|
+
/**
|
|
2565
|
+
* Valid encryption levels for is_encrypted_at_least comparisons.
|
|
2566
|
+
*/
|
|
2567
|
+
const VALID_ENCRYPTION_LEVELS = [
|
|
2568
|
+
"plaintext",
|
|
2569
|
+
"channel",
|
|
2570
|
+
"sealed",
|
|
2571
|
+
];
|
|
2572
|
+
/**
|
|
2573
|
+
* Encryption level ordering for comparison.
|
|
2574
|
+
* Higher number = stronger encryption.
|
|
2575
|
+
*/
|
|
2576
|
+
const ENCRYPTION_LEVEL_ORDER = {
|
|
2577
|
+
plaintext: 0,
|
|
2578
|
+
channel: 1,
|
|
2579
|
+
sealed: 2,
|
|
2580
|
+
};
|
|
2581
|
+
/**
|
|
2582
|
+
* Normalizes an encryption algorithm string to an EncryptionLevel.
|
|
2583
|
+
*
|
|
2584
|
+
* Mapping rules:
|
|
2585
|
+
* - null/undefined => "plaintext" (no encryption present)
|
|
2586
|
+
* - alg contains "-channel" => "channel" (e.g., "chacha20-poly1305-channel")
|
|
2587
|
+
* - alg contains "-sealed" => "sealed" (explicit sealed marker)
|
|
2588
|
+
* - alg matches ECDH-ES pattern with AEAD cipher => "sealed" (e.g., "ECDH-ES+A256GCM")
|
|
2589
|
+
* - otherwise => "unknown"
|
|
2590
|
+
*
|
|
2591
|
+
* Currently supported algorithms:
|
|
2592
|
+
* - Channel: "chacha20-poly1305-channel"
|
|
2593
|
+
* - Sealed: "ECDH-ES+A256GCM"
|
|
2594
|
+
*
|
|
2595
|
+
* This helper is centralized to ensure consistent mapping across TS and Python.
|
|
2596
|
+
*/
|
|
2597
|
+
function normalizeEncryptionLevelFromAlg(alg) {
|
|
2598
|
+
if (alg === null || alg === undefined) {
|
|
2599
|
+
return "plaintext";
|
|
2600
|
+
}
|
|
2601
|
+
const algLower = alg.toLowerCase();
|
|
2602
|
+
// Check for channel encryption (e.g., "chacha20-poly1305-channel")
|
|
2603
|
+
// Must check before other patterns since channel suffix is explicit
|
|
2604
|
+
if (algLower.includes("-channel")) {
|
|
2605
|
+
return "channel";
|
|
2606
|
+
}
|
|
2607
|
+
// Check for explicit sealed marker
|
|
2608
|
+
if (algLower.includes("-sealed")) {
|
|
2609
|
+
return "sealed";
|
|
2610
|
+
}
|
|
2611
|
+
// ECDH-ES key agreement with AEAD cipher => sealed encryption
|
|
2612
|
+
// Pattern: "ECDH-ES+A256GCM", "ECDH-ES+A128GCM", etc.
|
|
2613
|
+
if (algLower.startsWith("ecdh-es") && algLower.includes("+a")) {
|
|
2614
|
+
return "sealed";
|
|
2615
|
+
}
|
|
2616
|
+
return "unknown";
|
|
2617
|
+
}
|
|
2618
|
+
/**
|
|
2619
|
+
* Creates security bindings from an envelope's sec header.
|
|
2620
|
+
* Exposes only metadata, never raw values like sig.val or enc.val.
|
|
2621
|
+
*/
|
|
2622
|
+
function createSecurityBindings(sec) {
|
|
2623
|
+
const sigPresent = sec?.sig !== undefined;
|
|
2624
|
+
const encPresent = sec?.enc !== undefined;
|
|
2625
|
+
return {
|
|
2626
|
+
sig: {
|
|
2627
|
+
present: sigPresent,
|
|
2628
|
+
kid: sec?.sig?.kid ?? null,
|
|
2629
|
+
},
|
|
2630
|
+
enc: {
|
|
2631
|
+
present: encPresent,
|
|
2632
|
+
alg: sec?.enc?.alg ?? null,
|
|
2633
|
+
kid: sec?.enc?.kid ?? null,
|
|
2634
|
+
level: encPresent
|
|
2635
|
+
? normalizeEncryptionLevelFromAlg(sec?.enc?.alg ?? null)
|
|
2636
|
+
: "plaintext",
|
|
2637
|
+
},
|
|
2638
|
+
};
|
|
2639
|
+
}
|
|
2562
2640
|
/**
|
|
2563
2641
|
* Checks if a value is null.
|
|
2564
2642
|
*/
|
|
@@ -2567,9 +2645,21 @@ function isNull(value) {
|
|
|
2567
2645
|
}
|
|
2568
2646
|
/**
|
|
2569
2647
|
* Creates a function registry with auth helpers installed.
|
|
2648
|
+
*
|
|
2649
|
+
* This registry extends the base builtins with:
|
|
2650
|
+
* - Scope builtins: has_scope, has_any_scope, has_all_scopes
|
|
2651
|
+
* - Security builtins: is_signed, encryption_level, is_encrypted, is_encrypted_at_least
|
|
2570
2652
|
*/
|
|
2571
|
-
function createAuthFunctionRegistry(
|
|
2572
|
-
|
|
2653
|
+
function createAuthFunctionRegistry(grantedScopesOrOptions = []) {
|
|
2654
|
+
// Handle both old signature (array) and new signature (options object)
|
|
2655
|
+
const options = Array.isArray(grantedScopesOrOptions)
|
|
2656
|
+
? { grantedScopes: grantedScopesOrOptions }
|
|
2657
|
+
: grantedScopesOrOptions;
|
|
2658
|
+
const scopes = options.grantedScopes ?? [];
|
|
2659
|
+
const secBindings = options.securityBindings ?? {
|
|
2660
|
+
sig: { present: false, kid: null },
|
|
2661
|
+
enc: { present: false, alg: null, kid: null, level: "plaintext" },
|
|
2662
|
+
};
|
|
2573
2663
|
/**
|
|
2574
2664
|
* Checks if any granted scope matches a pattern (using glob syntax).
|
|
2575
2665
|
*/
|
|
@@ -2625,11 +2715,85 @@ function createAuthFunctionRegistry(grantedScopes = []) {
|
|
|
2625
2715
|
}
|
|
2626
2716
|
return values.every((scope) => matchesScope(scope));
|
|
2627
2717
|
};
|
|
2718
|
+
// ============================================================
|
|
2719
|
+
// Security posture builtins
|
|
2720
|
+
// ============================================================
|
|
2721
|
+
/**
|
|
2722
|
+
* is_signed() -> bool
|
|
2723
|
+
*
|
|
2724
|
+
* Returns true if the envelope has a signature present.
|
|
2725
|
+
* No arguments required.
|
|
2726
|
+
*/
|
|
2727
|
+
const is_signed = (args) => {
|
|
2728
|
+
assertArgCount(args, 0, "is_signed");
|
|
2729
|
+
return secBindings.sig.present;
|
|
2730
|
+
};
|
|
2731
|
+
/**
|
|
2732
|
+
* encryption_level() -> string
|
|
2733
|
+
*
|
|
2734
|
+
* Returns the normalized encryption level: "plaintext" | "channel" | "sealed" | "unknown"
|
|
2735
|
+
* No arguments required.
|
|
2736
|
+
*/
|
|
2737
|
+
const encryption_level = (args) => {
|
|
2738
|
+
assertArgCount(args, 0, "encryption_level");
|
|
2739
|
+
return secBindings.enc.level;
|
|
2740
|
+
};
|
|
2741
|
+
/**
|
|
2742
|
+
* is_encrypted() -> bool
|
|
2743
|
+
*
|
|
2744
|
+
* Returns true if the encryption level is not "plaintext".
|
|
2745
|
+
* This means the envelope has some form of encryption (channel, sealed, or unknown).
|
|
2746
|
+
* No arguments required.
|
|
2747
|
+
*/
|
|
2748
|
+
const is_encrypted = (args) => {
|
|
2749
|
+
assertArgCount(args, 0, "is_encrypted");
|
|
2750
|
+
return secBindings.enc.level !== "plaintext";
|
|
2751
|
+
};
|
|
2752
|
+
/**
|
|
2753
|
+
* is_encrypted_at_least(level: string) -> bool
|
|
2754
|
+
*
|
|
2755
|
+
* Returns true if the envelope's encryption level meets or exceeds the required level.
|
|
2756
|
+
*
|
|
2757
|
+
* Level ordering: plaintext < channel < sealed
|
|
2758
|
+
*
|
|
2759
|
+
* Special handling:
|
|
2760
|
+
* - "unknown" encryption level does NOT satisfy "channel" or "sealed" (conservative)
|
|
2761
|
+
* - "plaintext" is always satisfied (any envelope meets at least plaintext)
|
|
2762
|
+
* - null argument => false (predicate-style)
|
|
2763
|
+
* - invalid level string => BuiltinError
|
|
2764
|
+
*/
|
|
2765
|
+
const is_encrypted_at_least = (args) => {
|
|
2766
|
+
assertArgCount(args, 1, "is_encrypted_at_least");
|
|
2767
|
+
const requiredLevel = getArg(args, 0, "is_encrypted_at_least");
|
|
2768
|
+
// Null-tolerant: return false if level is null
|
|
2769
|
+
if (!assertStringOrNull(requiredLevel, "level", "is_encrypted_at_least")) {
|
|
2770
|
+
return false;
|
|
2771
|
+
}
|
|
2772
|
+
// Validate required level
|
|
2773
|
+
if (!VALID_ENCRYPTION_LEVELS.includes(requiredLevel)) {
|
|
2774
|
+
throw new BuiltinError("is_encrypted_at_least", `level must be one of: ${VALID_ENCRYPTION_LEVELS.join(", ")}; got "${requiredLevel}"`);
|
|
2775
|
+
}
|
|
2776
|
+
const currentLevel = secBindings.enc.level;
|
|
2777
|
+
const requiredOrder = ENCRYPTION_LEVEL_ORDER[requiredLevel] ?? 0;
|
|
2778
|
+
const currentOrder = ENCRYPTION_LEVEL_ORDER[currentLevel];
|
|
2779
|
+
// If current level is "unknown", it only satisfies "plaintext"
|
|
2780
|
+
if (currentOrder === undefined) {
|
|
2781
|
+
// "unknown" is treated as NOT meeting channel/sealed requirements
|
|
2782
|
+
return requiredOrder === 0; // Only plaintext is satisfied by unknown
|
|
2783
|
+
}
|
|
2784
|
+
return currentOrder >= requiredOrder;
|
|
2785
|
+
};
|
|
2628
2786
|
return new Map([
|
|
2629
2787
|
...BUILTIN_FUNCTIONS,
|
|
2788
|
+
// Scope builtins
|
|
2630
2789
|
["has_scope", has_scope],
|
|
2631
2790
|
["has_any_scope", has_any_scope],
|
|
2632
2791
|
["has_all_scopes", has_all_scopes],
|
|
2792
|
+
// Security posture builtins
|
|
2793
|
+
["is_signed", is_signed],
|
|
2794
|
+
["encryption_level", encryption_level],
|
|
2795
|
+
["is_encrypted", is_encrypted],
|
|
2796
|
+
["is_encrypted_at_least", is_encrypted_at_least],
|
|
2633
2797
|
]);
|
|
2634
2798
|
}
|
|
2635
2799
|
/**
|
|
@@ -2772,19 +2936,33 @@ function extractClaims(context) {
|
|
|
2772
2936
|
}
|
|
2773
2937
|
/**
|
|
2774
2938
|
* Creates a safe envelope subset for expression bindings.
|
|
2939
|
+
*
|
|
2940
|
+
* Exposes:
|
|
2941
|
+
* - id, sid, traceId, corrId, flowId, to
|
|
2942
|
+
* - frame: { type }
|
|
2943
|
+
* - sec: { sig: { present, kid }, enc: { present, alg, kid, level } }
|
|
2944
|
+
*
|
|
2945
|
+
* IMPORTANT: Does NOT expose raw security values (sig.val, enc.val).
|
|
2775
2946
|
*/
|
|
2776
2947
|
function createEnvelopeBindings(envelope) {
|
|
2777
2948
|
const frame = envelope.frame;
|
|
2778
2949
|
const envelopeRecord = envelope;
|
|
2950
|
+
const sec = envelopeRecord.sec;
|
|
2951
|
+
const securityBindings = createSecurityBindings(sec);
|
|
2779
2952
|
return {
|
|
2780
|
-
|
|
2781
|
-
|
|
2782
|
-
|
|
2783
|
-
|
|
2784
|
-
|
|
2785
|
-
|
|
2786
|
-
|
|
2787
|
-
:
|
|
2953
|
+
bindings: {
|
|
2954
|
+
id: envelope.id ?? null,
|
|
2955
|
+
sid: envelopeRecord.sid ?? null,
|
|
2956
|
+
traceId: envelopeRecord.traceId ?? null,
|
|
2957
|
+
corrId: envelopeRecord.corrId ?? null,
|
|
2958
|
+
flowId: envelopeRecord.flowId ?? null,
|
|
2959
|
+
to: extractAddress(envelope) ?? null,
|
|
2960
|
+
frame: frame
|
|
2961
|
+
? { type: frame.type ?? null }
|
|
2962
|
+
: { type: null },
|
|
2963
|
+
sec: securityBindings,
|
|
2964
|
+
},
|
|
2965
|
+
securityBindings,
|
|
2788
2966
|
};
|
|
2789
2967
|
}
|
|
2790
2968
|
/**
|
|
@@ -2938,11 +3116,12 @@ class AdvancedAuthorizationPolicy {
|
|
|
2938
3116
|
continue;
|
|
2939
3117
|
}
|
|
2940
3118
|
if (rule.whenAst) {
|
|
2941
|
-
// Lazy initialization of expression bindings
|
|
3119
|
+
// Lazy initialization of expression bindings and security context
|
|
2942
3120
|
if (!expressionBindings) {
|
|
3121
|
+
const envelopeResult = createEnvelopeBindings(envelope);
|
|
2943
3122
|
expressionBindings = {
|
|
2944
3123
|
claims: extractClaims(context),
|
|
2945
|
-
envelope:
|
|
3124
|
+
envelope: envelopeResult.bindings,
|
|
2946
3125
|
delivery: createDeliveryBindings(context, resolvedAction),
|
|
2947
3126
|
node: createNodeBindings(node),
|
|
2948
3127
|
time: {
|
|
@@ -2950,9 +3129,13 @@ class AdvancedAuthorizationPolicy {
|
|
|
2950
3129
|
now_iso: new Date().toISOString(),
|
|
2951
3130
|
},
|
|
2952
3131
|
};
|
|
3132
|
+
// Create function registry with security bindings for security builtins
|
|
3133
|
+
functionRegistry = createAuthFunctionRegistry({
|
|
3134
|
+
grantedScopes,
|
|
3135
|
+
securityBindings: envelopeResult.securityBindings,
|
|
3136
|
+
});
|
|
2953
3137
|
}
|
|
2954
|
-
const functions = functionRegistry
|
|
2955
|
-
functionRegistry = functions;
|
|
3138
|
+
const functions = functionRegistry;
|
|
2956
3139
|
const evalContext = {
|
|
2957
3140
|
bindings: expressionBindings,
|
|
2958
3141
|
limits: this.expressionLimits,
|
|
@@ -12999,4 +13182,4 @@ if (isNode && proc && proc.env) {
|
|
|
12999
13182
|
}
|
|
13000
13183
|
}
|
|
13001
13184
|
|
|
13002
|
-
export { FACTORY_META$f as ADVANCED_AUTHORIZATION_POLICY_FACTORY_META, FACTORY_META$a as ADVANCED_EDDSA_ENVELOPE_SIGNER_FACTORY_META, FACTORY_META$9 as ADVANCED_EDDSA_ENVELOPE_VERIFIER_FACTORY_META, FACTORY_META$5 as ADVANCED_WELCOME_FACTORY_META, AFTHelper, AFTLoadBalancerStickinessManager, AFTLoadBalancerStickinessManagerFactory, AFTReplicaStickinessManager, AFTReplicaStickinessManagerFactory, FACTORY_META$7 as AFT_LOAD_BALANCER_FACTORY_META, FACTORY_META$6 as AFT_REPLICA_FACTORY_META, AdvancedAuthorizationPolicy, AdvancedAuthorizationPolicyFactory, AdvancedEdDSAEnvelopeSignerFactory, AdvancedEdDSAEnvelopeVerifierFactory, AdvancedWelcomeService, AdvancedWelcomeServiceFactory, FACTORY_META$2 as BROWSER_TRUST_STORE_PROVIDER_FACTORY_META, BUILTIN_FUNCTIONS, BrowserTrustStoreProviderFactory, BuiltinError, CAService, CAServiceClient, CAServiceFactory, CASigningService, CA_SERVICE_FACTORY_BASE_TYPE, CertificateRequestError, CompositeEncryptionManager, CompositeEncryptionManagerFactory, FACTORY_META$4 as DEFAULT_CERTIFICATE_MANAGER_FACTORY_META, DEFAULT_EXPRESSION_LIMITS, FACTORY_META$c as DEFAULT_SECURE_CHANNEL_MANAGER_FACTORY_META, DEFAULT_STICKINESS_SECURITY_LEVEL, DefaultCAService, DefaultCAServiceFactory, DefaultCertificateManager, DefaultCertificateManagerFactory, DefaultSecureChannelManager, DefaultSecureChannelManagerFactory, ENV_FAME_CA_CERT_FILE, ENV_FAME_CA_CERT_PEM, ENV_FAME_CA_KEY_FILE, ENV_FAME_CA_KEY_PEM, ENV_FAME_INTERMEDIATE_CHAIN_FILE, ENV_FAME_INTERMEDIATE_CHAIN_PEM, ENV_FAME_SIGNING_CERT_FILE, ENV_FAME_SIGNING_CERT_PEM, ENV_FAME_SIGNING_KEY_FILE, ENV_FAME_SIGNING_KEY_PEM, FACTORY_META$3 as ENV_TRUST_STORE_PROVIDER_FACTORY_META, ENV_VAR_FAME_CA_SERVICE_URL, EdDSAEnvelopeVerifier, EnvTrustStoreProviderFactory, EvaluationError, Evaluator, ExpressionError, GRANT_PURPOSE_CA_SIGN, LOGICALS_OID, LimitExceededError, NODE_ID_OID, NoAFTSigner, NullTrustStoreProvider, PROFILE_NAME_STRICT_OVERLAY, ParseError, Parser, SID_OID, SidOnlyAFTVerifier, SignedAFTSigner, SignedOptionalAFTVerifier, StickinessMode, StrictAFTVerifier, TRUST_STORE_PROVIDER_FACTORY_BASE_TYPE, Tokenizer, TokenizerError, TrustStoreProviderFactory, TypeError, UnsignedAFTSigner, VERSION, X5CKeyManager, X5CKeyManagerFactory, FACTORY_META$8 as X5C_KEY_MANAGER_FACTORY_META, __advancedSecurityPluginLoader, astToString, base64UrlDecode, base64UrlEncode, calculateAstDepth, callBuiltin, index as channelEncryption, checkArrayLength, checkAstDepth, checkAstNodeCount, checkExpressionLength, checkFunctionArgCount, checkGlobPatternLength, checkRegexPatternLength, countAstNodes, createAftHelper, createAftPayload, createAftReplicaStickinessManager, createAftSigner, createAftVerifier, createAuthFunctionRegistry, createEd25519Csr, createEd25519CsrFromPem, createTestCA, evaluate, evaluateAsBoolean, extractCertificateInfo, extractLogicalHostsFromCert, extractNodeIdFromCert, extractSidFromCert, extractSidFromSpiffeId, extractSpiffeIdFromCert, formatCertificateInfo, getTypeName, isBuiltinFunction, normalizeJsValue, normalizeStickinessMode, parse, publicKeyFromX5c, registerAdvancedSecurityFactories, index$1 as sealedEncryption, serializeAftClaims, serializeAftHeader, tokenize, utf8Decode, validateJwkX5cCertificate, verifyCertSidIntegrity };
|
|
13185
|
+
export { FACTORY_META$f as ADVANCED_AUTHORIZATION_POLICY_FACTORY_META, FACTORY_META$a as ADVANCED_EDDSA_ENVELOPE_SIGNER_FACTORY_META, FACTORY_META$9 as ADVANCED_EDDSA_ENVELOPE_VERIFIER_FACTORY_META, FACTORY_META$5 as ADVANCED_WELCOME_FACTORY_META, AFTHelper, AFTLoadBalancerStickinessManager, AFTLoadBalancerStickinessManagerFactory, AFTReplicaStickinessManager, AFTReplicaStickinessManagerFactory, FACTORY_META$7 as AFT_LOAD_BALANCER_FACTORY_META, FACTORY_META$6 as AFT_REPLICA_FACTORY_META, AdvancedAuthorizationPolicy, AdvancedAuthorizationPolicyFactory, AdvancedEdDSAEnvelopeSignerFactory, AdvancedEdDSAEnvelopeVerifierFactory, AdvancedWelcomeService, AdvancedWelcomeServiceFactory, FACTORY_META$2 as BROWSER_TRUST_STORE_PROVIDER_FACTORY_META, BUILTIN_FUNCTIONS, BrowserTrustStoreProviderFactory, BuiltinError, CAService, CAServiceClient, CAServiceFactory, CASigningService, CA_SERVICE_FACTORY_BASE_TYPE, CertificateRequestError, CompositeEncryptionManager, CompositeEncryptionManagerFactory, FACTORY_META$4 as DEFAULT_CERTIFICATE_MANAGER_FACTORY_META, DEFAULT_EXPRESSION_LIMITS, FACTORY_META$c as DEFAULT_SECURE_CHANNEL_MANAGER_FACTORY_META, DEFAULT_STICKINESS_SECURITY_LEVEL, DefaultCAService, DefaultCAServiceFactory, DefaultCertificateManager, DefaultCertificateManagerFactory, DefaultSecureChannelManager, DefaultSecureChannelManagerFactory, ENV_FAME_CA_CERT_FILE, ENV_FAME_CA_CERT_PEM, ENV_FAME_CA_KEY_FILE, ENV_FAME_CA_KEY_PEM, ENV_FAME_INTERMEDIATE_CHAIN_FILE, ENV_FAME_INTERMEDIATE_CHAIN_PEM, ENV_FAME_SIGNING_CERT_FILE, ENV_FAME_SIGNING_CERT_PEM, ENV_FAME_SIGNING_KEY_FILE, ENV_FAME_SIGNING_KEY_PEM, FACTORY_META$3 as ENV_TRUST_STORE_PROVIDER_FACTORY_META, ENV_VAR_FAME_CA_SERVICE_URL, EdDSAEnvelopeVerifier, EnvTrustStoreProviderFactory, EvaluationError, Evaluator, ExpressionError, GRANT_PURPOSE_CA_SIGN, LOGICALS_OID, LimitExceededError, NODE_ID_OID, NoAFTSigner, NullTrustStoreProvider, PROFILE_NAME_STRICT_OVERLAY, ParseError, Parser, SID_OID, SidOnlyAFTVerifier, SignedAFTSigner, SignedOptionalAFTVerifier, StickinessMode, StrictAFTVerifier, TRUST_STORE_PROVIDER_FACTORY_BASE_TYPE, Tokenizer, TokenizerError, TrustStoreProviderFactory, TypeError, UnsignedAFTSigner, VERSION, X5CKeyManager, X5CKeyManagerFactory, FACTORY_META$8 as X5C_KEY_MANAGER_FACTORY_META, __advancedSecurityPluginLoader, astToString, base64UrlDecode, base64UrlEncode, calculateAstDepth, callBuiltin, index as channelEncryption, checkArrayLength, checkAstDepth, checkAstNodeCount, checkExpressionLength, checkFunctionArgCount, checkGlobPatternLength, checkRegexPatternLength, countAstNodes, createAftHelper, createAftPayload, createAftReplicaStickinessManager, createAftSigner, createAftVerifier, createAuthFunctionRegistry, createEd25519Csr, createEd25519CsrFromPem, createSecurityBindings, createTestCA, evaluate, evaluateAsBoolean, extractCertificateInfo, extractLogicalHostsFromCert, extractNodeIdFromCert, extractSidFromCert, extractSidFromSpiffeId, extractSpiffeIdFromCert, formatCertificateInfo, getTypeName, isBuiltinFunction, normalizeEncryptionLevelFromAlg, normalizeJsValue, normalizeStickinessMode, parse, publicKeyFromX5c, registerAdvancedSecurityFactories, index$1 as sealedEncryption, serializeAftClaims, serializeAftHeader, tokenize, utf8Decode, validateJwkX5cCertificate, verifyCertSidIntegrity };
|
package/dist/types/naylence/fame/security/auth/policy/advanced-authorization-policy.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"advanced-authorization-policy.d.ts","sourceRoot":"","sources":["../../../../../../../src/naylence/fame/security/auth/policy/advanced-authorization-policy.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EACV,mBAAmB,EACnB,YAAY,EACb,MAAM,gBAAgB,CAAC;AAExB,OAAO,KAAK,EACV,mBAAmB,EACnB,qBAAqB,EAErB,6BAA6B,EAE7B,UAAU,EAGX,MAAM,mBAAmB,CAAC;AAY3B;;;;;;;GAOG;AACH,eAAO,MAAM,iBAAiB,ySAmBpB,CAAC;AAEX,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAQlD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"advanced-authorization-policy.d.ts","sourceRoot":"","sources":["../../../../../../../src/naylence/fame/security/auth/policy/advanced-authorization-policy.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EACV,mBAAmB,EACnB,YAAY,EACb,MAAM,gBAAgB,CAAC;AAExB,OAAO,KAAK,EACV,mBAAmB,EACnB,qBAAqB,EAErB,6BAA6B,EAE7B,UAAU,EAGX,MAAM,mBAAmB,CAAC;AAY3B;;;;;;;GAOG;AACH,eAAO,MAAM,iBAAiB,ySAmBpB,CAAC;AAEX,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAQlD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAQhE;;GAEG;AACH,UAAU,MAAM;IACd,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IAC3D,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;CAC9D;AA6KD;;GAEG;AACH,MAAM,WAAW,kCAAkC;IACjD;;OAEG;IACH,gBAAgB,EAAE,6BAA6B,CAAC;IAEhD;;;OAGG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAE9B;;;OAGG;IACH,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;IAEpC;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;;;;;;;;GASG;AACH,qBAAa,2BAA4B,YAAW,mBAAmB;IACrE,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAmB;IACjD,OAAO,CAAC,QAAQ,CAAC,aAAa,CAA2B;IACzD,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAmB;IACpD,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;gBAEpB,OAAO,EAAE,kCAAkC;IAkCvD;;OAEG;IACG,eAAe,CACnB,IAAI,EAAE,QAAQ,EACd,QAAQ,EAAE,YAAY,EACtB,OAAO,CAAC,EAAE,mBAAmB,EAC7B,MAAM,CAAC,EAAE,UAAU,GAClB,OAAO,CAAC,qBAAqB,CAAC;IAmNjC,OAAO,CAAC,qBAAqB;IAY7B,OAAO,CAAC,uBAAuB;IAU/B,OAAO,CAAC,YAAY;IAOpB,OAAO,CAAC,WAAW;IAuFnB,OAAO,CAAC,cAAc;IAiDtB,OAAO,CAAC,cAAc;IA+DtB,OAAO,CAAC,iBAAiB;IA6DzB,OAAO,CAAC,kBAAkB;IA6D1B,OAAO,CAAC,oBAAoB;IAmB5B,OAAO,CAAC,wBAAwB;CAcjC"}
|
|
@@ -4,11 +4,81 @@
|
|
|
4
4
|
* Null handling semantics:
|
|
5
5
|
* - Scope predicate builtins (has_scope, has_any_scope, has_all_scopes)
|
|
6
6
|
* return `false` when passed `null` for required args.
|
|
7
|
+
* - Security predicate builtins (is_signed, is_encrypted, is_encrypted_at_least)
|
|
8
|
+
* return `false` when the envelope lacks the required security posture.
|
|
7
9
|
* - Wrong non-null types still raise BuiltinError to surface real bugs.
|
|
8
10
|
*/
|
|
9
11
|
import { type FunctionRegistry } from "../../../expr/index.js";
|
|
12
|
+
/**
|
|
13
|
+
* Encryption level type for normalized security posture.
|
|
14
|
+
*/
|
|
15
|
+
export type EncryptionLevel = "plaintext" | "channel" | "sealed" | "unknown";
|
|
16
|
+
/**
|
|
17
|
+
* Normalizes an encryption algorithm string to an EncryptionLevel.
|
|
18
|
+
*
|
|
19
|
+
* Mapping rules:
|
|
20
|
+
* - null/undefined => "plaintext" (no encryption present)
|
|
21
|
+
* - alg contains "-channel" => "channel" (e.g., "chacha20-poly1305-channel")
|
|
22
|
+
* - alg contains "-sealed" => "sealed" (explicit sealed marker)
|
|
23
|
+
* - alg matches ECDH-ES pattern with AEAD cipher => "sealed" (e.g., "ECDH-ES+A256GCM")
|
|
24
|
+
* - otherwise => "unknown"
|
|
25
|
+
*
|
|
26
|
+
* Currently supported algorithms:
|
|
27
|
+
* - Channel: "chacha20-poly1305-channel"
|
|
28
|
+
* - Sealed: "ECDH-ES+A256GCM"
|
|
29
|
+
*
|
|
30
|
+
* This helper is centralized to ensure consistent mapping across TS and Python.
|
|
31
|
+
*/
|
|
32
|
+
export declare function normalizeEncryptionLevelFromAlg(alg: string | null | undefined): EncryptionLevel;
|
|
33
|
+
/**
|
|
34
|
+
* Security metadata bindings exposed to expressions.
|
|
35
|
+
* This is the shape of the `envelope.sec` binding.
|
|
36
|
+
*/
|
|
37
|
+
export interface SecurityBindings {
|
|
38
|
+
sig: {
|
|
39
|
+
present: boolean;
|
|
40
|
+
kid: string | null;
|
|
41
|
+
};
|
|
42
|
+
enc: {
|
|
43
|
+
present: boolean;
|
|
44
|
+
alg: string | null;
|
|
45
|
+
kid: string | null;
|
|
46
|
+
level: EncryptionLevel;
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Creates security bindings from an envelope's sec header.
|
|
51
|
+
* Exposes only metadata, never raw values like sig.val or enc.val.
|
|
52
|
+
*/
|
|
53
|
+
export declare function createSecurityBindings(sec: {
|
|
54
|
+
sig?: {
|
|
55
|
+
kid?: string;
|
|
56
|
+
};
|
|
57
|
+
enc?: {
|
|
58
|
+
alg?: string;
|
|
59
|
+
kid?: string;
|
|
60
|
+
};
|
|
61
|
+
} | undefined): SecurityBindings;
|
|
62
|
+
/**
|
|
63
|
+
* Options for creating an auth function registry.
|
|
64
|
+
*/
|
|
65
|
+
export interface AuthFunctionRegistryOptions {
|
|
66
|
+
/**
|
|
67
|
+
* Granted scopes for scope checking builtins.
|
|
68
|
+
*/
|
|
69
|
+
grantedScopes?: readonly string[];
|
|
70
|
+
/**
|
|
71
|
+
* Security bindings for security posture builtins.
|
|
72
|
+
* If not provided, is_signed returns false and encryption_level returns "plaintext".
|
|
73
|
+
*/
|
|
74
|
+
securityBindings?: SecurityBindings;
|
|
75
|
+
}
|
|
10
76
|
/**
|
|
11
77
|
* Creates a function registry with auth helpers installed.
|
|
78
|
+
*
|
|
79
|
+
* This registry extends the base builtins with:
|
|
80
|
+
* - Scope builtins: has_scope, has_any_scope, has_all_scopes
|
|
81
|
+
* - Security builtins: is_signed, encryption_level, is_encrypted, is_encrypted_at_least
|
|
12
82
|
*/
|
|
13
|
-
export declare function createAuthFunctionRegistry(
|
|
83
|
+
export declare function createAuthFunctionRegistry(grantedScopesOrOptions?: readonly string[] | AuthFunctionRegistryOptions): FunctionRegistry;
|
|
14
84
|
//# sourceMappingURL=expr-builtins.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"expr-builtins.d.ts","sourceRoot":"","sources":["../../../../../../../src/naylence/fame/security/auth/policy/expr-builtins.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"expr-builtins.d.ts","sourceRoot":"","sources":["../../../../../../../src/naylence/fame/security/auth/policy/expr-builtins.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAKL,KAAK,gBAAgB,EACtB,MAAM,wBAAwB,CAAC;AAGhC;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG,WAAW,GAAG,SAAS,GAAG,QAAQ,GAAG,SAAS,CAAC;AAqB7E;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,+BAA+B,CAC7C,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAC7B,eAAe,CAyBjB;AAED;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAC/B,GAAG,EAAE;QACH,OAAO,EAAE,OAAO,CAAC;QACjB,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;KACpB,CAAC;IACF,GAAG,EAAE;QACH,OAAO,EAAE,OAAO,CAAC;QACjB,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;QACnB,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;QACnB,KAAK,EAAE,eAAe,CAAC;KACxB,CAAC;CACH;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CACpC,GAAG,EAAE;IAAE,GAAG,CAAC,EAAE;QAAE,GAAG,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAAC,GAAG,CAAC,EAAE;QAAE,GAAG,CAAC,EAAE,MAAM,CAAC;QAAC,GAAG,CAAC,EAAE,MAAM,CAAA;KAAE,CAAA;CAAE,GAAG,SAAS,GAChF,gBAAgB,CAkBlB;AASD;;GAEG;AACH,MAAM,WAAW,2BAA2B;IAC1C;;OAEG;IACH,aAAa,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAElC;;;OAGG;IACH,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;CACrC;AAED;;;;;;GAMG;AACH,wBAAgB,0BAA0B,CACxC,sBAAsB,GAAE,SAAS,MAAM,EAAE,GAAG,2BAAgC,GAC3E,gBAAgB,CAiKlB"}
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* @packageDocumentation
|
|
8
8
|
*/
|
|
9
|
-
export { createAuthFunctionRegistry } from "./expr-builtins.js";
|
|
9
|
+
export { createAuthFunctionRegistry, createSecurityBindings, normalizeEncryptionLevelFromAlg, type AuthFunctionRegistryOptions, type EncryptionLevel, type SecurityBindings, } from "./expr-builtins.js";
|
|
10
10
|
export { AdvancedAuthorizationPolicy, type AdvancedAuthorizationPolicyOptions, } from "./advanced-authorization-policy.js";
|
|
11
11
|
export { AdvancedAuthorizationPolicyFactory, FACTORY_META as ADVANCED_AUTHORIZATION_POLICY_FACTORY_META, type AdvancedAuthorizationPolicyConfig, } from "./advanced-authorization-policy-factory.js";
|
|
12
12
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../src/naylence/fame/security/auth/policy/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../src/naylence/fame/security/auth/policy/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,EACL,0BAA0B,EAC1B,sBAAsB,EACtB,+BAA+B,EAC/B,KAAK,2BAA2B,EAChC,KAAK,eAAe,EACpB,KAAK,gBAAgB,GACtB,MAAM,oBAAoB,CAAC;AAG5B,OAAO,EACL,2BAA2B,EAC3B,KAAK,kCAAkC,GACxC,MAAM,oCAAoC,CAAC;AAG5C,OAAO,EACL,kCAAkC,EAClC,YAAY,IAAI,0CAA0C,EAC1D,KAAK,iCAAiC,GACvC,MAAM,4CAA4C,CAAC"}
|
package/dist/types/version.d.ts
CHANGED
package/package.json
CHANGED