@naylence/runtime 0.3.21 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (88) hide show
  1. package/dist/browser/index.cjs +3368 -1393
  2. package/dist/browser/index.mjs +3324 -1387
  3. package/dist/cjs/naylence/fame/factory-manifest.js +8 -0
  4. package/dist/cjs/naylence/fame/node/node-event-listener.js +4 -0
  5. package/dist/cjs/naylence/fame/security/auth/authorization-profile-factory.js +165 -0
  6. package/dist/cjs/naylence/fame/security/auth/default-policy-authorizer-factory.js +147 -0
  7. package/dist/cjs/naylence/fame/security/auth/default-policy-authorizer.js +291 -0
  8. package/dist/cjs/naylence/fame/security/auth/oauth2-authorizer-factory.js +7 -0
  9. package/dist/cjs/naylence/fame/security/auth/oauth2-authorizer.js +19 -4
  10. package/dist/cjs/naylence/fame/security/auth/policy/authorization-policy-definition.js +60 -0
  11. package/dist/cjs/naylence/fame/security/auth/policy/authorization-policy-factory.js +35 -0
  12. package/dist/cjs/naylence/fame/security/auth/policy/authorization-policy-source-factory.js +35 -0
  13. package/dist/cjs/naylence/fame/security/auth/policy/authorization-policy-source.js +2 -0
  14. package/dist/cjs/naylence/fame/security/auth/policy/authorization-policy.js +2 -0
  15. package/dist/cjs/naylence/fame/security/auth/policy/basic-authorization-policy-factory.js +99 -0
  16. package/dist/cjs/naylence/fame/security/auth/policy/basic-authorization-policy.js +449 -0
  17. package/dist/cjs/naylence/fame/security/auth/policy/index.js +40 -0
  18. package/dist/cjs/naylence/fame/security/auth/policy/local-file-authorization-policy-source-factory.js +101 -0
  19. package/dist/cjs/naylence/fame/security/auth/policy/local-file-authorization-policy-source.js +164 -0
  20. package/dist/cjs/naylence/fame/security/auth/policy/pattern-matcher.js +195 -0
  21. package/dist/cjs/naylence/fame/security/auth/policy/scope-matcher.js +169 -0
  22. package/dist/cjs/naylence/fame/security/auth/policy-authorizer.js +2 -0
  23. package/dist/cjs/naylence/fame/security/default-security-manager.js +94 -0
  24. package/dist/cjs/naylence/fame/security/index.js +22 -1
  25. package/dist/cjs/naylence/fame/security/node-security-profile-factory.js +15 -73
  26. package/dist/cjs/naylence/fame/sentinel/router.js +67 -1
  27. package/dist/cjs/naylence/fame/sentinel/sentinel.js +46 -2
  28. package/dist/cjs/naylence/fame/util/register-runtime-factories.js +2 -0
  29. package/dist/cjs/version.js +2 -2
  30. package/dist/esm/naylence/fame/factory-manifest.js +8 -0
  31. package/dist/esm/naylence/fame/node/node-event-listener.js +4 -0
  32. package/dist/esm/naylence/fame/security/auth/authorization-profile-factory.js +161 -0
  33. package/dist/esm/naylence/fame/security/auth/default-policy-authorizer-factory.js +110 -0
  34. package/dist/esm/naylence/fame/security/auth/default-policy-authorizer.js +287 -0
  35. package/dist/esm/naylence/fame/security/auth/oauth2-authorizer-factory.js +7 -0
  36. package/dist/esm/naylence/fame/security/auth/oauth2-authorizer.js +19 -4
  37. package/dist/esm/naylence/fame/security/auth/policy/authorization-policy-definition.js +57 -0
  38. package/dist/esm/naylence/fame/security/auth/policy/authorization-policy-factory.js +31 -0
  39. package/dist/esm/naylence/fame/security/auth/policy/authorization-policy-source-factory.js +31 -0
  40. package/dist/esm/naylence/fame/security/auth/policy/authorization-policy-source.js +1 -0
  41. package/dist/esm/naylence/fame/security/auth/policy/authorization-policy.js +1 -0
  42. package/dist/esm/naylence/fame/security/auth/policy/basic-authorization-policy-factory.js +62 -0
  43. package/dist/esm/naylence/fame/security/auth/policy/basic-authorization-policy.js +445 -0
  44. package/dist/esm/naylence/fame/security/auth/policy/index.js +20 -0
  45. package/dist/esm/naylence/fame/security/auth/policy/local-file-authorization-policy-source-factory.js +64 -0
  46. package/dist/esm/naylence/fame/security/auth/policy/local-file-authorization-policy-source.js +127 -0
  47. package/dist/esm/naylence/fame/security/auth/policy/pattern-matcher.js +185 -0
  48. package/dist/esm/naylence/fame/security/auth/policy/scope-matcher.js +162 -0
  49. package/dist/esm/naylence/fame/security/auth/policy-authorizer.js +1 -0
  50. package/dist/esm/naylence/fame/security/default-security-manager.js +94 -0
  51. package/dist/esm/naylence/fame/security/index.js +5 -1
  52. package/dist/esm/naylence/fame/security/node-security-profile-factory.js +14 -72
  53. package/dist/esm/naylence/fame/sentinel/router.js +64 -0
  54. package/dist/esm/naylence/fame/sentinel/sentinel.js +47 -3
  55. package/dist/esm/naylence/fame/util/register-runtime-factories.js +2 -0
  56. package/dist/esm/version.js +2 -2
  57. package/dist/node/index.cjs +3364 -1389
  58. package/dist/node/index.mjs +3324 -1387
  59. package/dist/node/node.cjs +3416 -1425
  60. package/dist/node/node.mjs +3376 -1423
  61. package/dist/types/naylence/fame/factory-manifest.d.ts +1 -1
  62. package/dist/types/naylence/fame/node/node-event-listener.d.ts +31 -0
  63. package/dist/types/naylence/fame/security/auth/authorization-profile-factory.d.ts +29 -0
  64. package/dist/types/naylence/fame/security/auth/authorizer.d.ts +37 -0
  65. package/dist/types/naylence/fame/security/auth/default-policy-authorizer-factory.d.ts +55 -0
  66. package/dist/types/naylence/fame/security/auth/default-policy-authorizer.d.ts +99 -0
  67. package/dist/types/naylence/fame/security/auth/oauth2-authorizer-factory.d.ts +2 -0
  68. package/dist/types/naylence/fame/security/auth/oauth2-authorizer.d.ts +2 -0
  69. package/dist/types/naylence/fame/security/auth/policy/authorization-policy-definition.d.ts +166 -0
  70. package/dist/types/naylence/fame/security/auth/policy/authorization-policy-factory.d.ts +38 -0
  71. package/dist/types/naylence/fame/security/auth/policy/authorization-policy-source-factory.d.ts +38 -0
  72. package/dist/types/naylence/fame/security/auth/policy/authorization-policy-source.d.ts +20 -0
  73. package/dist/types/naylence/fame/security/auth/policy/authorization-policy.d.ts +55 -0
  74. package/dist/types/naylence/fame/security/auth/policy/basic-authorization-policy-factory.d.ts +42 -0
  75. package/dist/types/naylence/fame/security/auth/policy/basic-authorization-policy.d.ts +78 -0
  76. package/dist/types/naylence/fame/security/auth/policy/index.d.ts +19 -0
  77. package/dist/types/naylence/fame/security/auth/policy/local-file-authorization-policy-source-factory.d.ts +51 -0
  78. package/dist/types/naylence/fame/security/auth/policy/local-file-authorization-policy-source.d.ts +67 -0
  79. package/dist/types/naylence/fame/security/auth/policy/pattern-matcher.d.ts +84 -0
  80. package/dist/types/naylence/fame/security/auth/policy/scope-matcher.d.ts +61 -0
  81. package/dist/types/naylence/fame/security/auth/policy-authorizer.d.ts +12 -0
  82. package/dist/types/naylence/fame/security/default-security-manager.d.ts +22 -0
  83. package/dist/types/naylence/fame/security/index.d.ts +5 -1
  84. package/dist/types/naylence/fame/security/node-security-profile-factory.d.ts +2 -0
  85. package/dist/types/naylence/fame/sentinel/router.d.ts +68 -0
  86. package/dist/types/naylence/fame/sentinel/sentinel.d.ts +16 -0
  87. package/dist/types/version.d.ts +1 -1
  88. package/package.json +1 -1
@@ -1,13 +1,33 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PROFILE_NAME_OPEN = exports.PROFILE_NAME_GATED_CALLBACK = exports.PROFILE_NAME_GATED = exports.PROFILE_NAME_OVERLAY_CALLBACK = exports.PROFILE_NAME_OVERLAY = exports.PROFILE_NAME_STRICT_OVERLAY = exports.ENV_VAR_JWT_REVERSE_AUTH_AUDIENCE = exports.ENV_VAR_JWT_REVERSE_AUTH_TRUSTED_ISSUER = exports.ENV_VAR_HMAC_SECRET = exports.ENV_VAR_DEFAULT_ENCRYPTION_LEVEL = exports.ENV_VAR_JWKS_URL = exports.ENV_VAR_JWT_AUDIENCE = exports.ENV_VAR_JWT_ALGORITHM = exports.ENV_VAR_JWT_TRUSTED_ISSUER = exports.CREDENTIAL_PROVIDER_FACTORY_BASE_TYPE = exports.EdDSAEnvelopeSigner = exports.encodeUtf8 = exports.immutableHeaders = exports.frameDigest = exports.decodeBase64Url = exports.canonicalJson = exports.SigningConfigClass = exports.SECURITY_MANAGER_FACTORY_BASE_TYPE = exports.SECURITY_POLICY_FACTORY_BASE_TYPE = exports.KEY_STORE_FACTORY_BASE_TYPE = exports.ATTACHMENT_KEY_VALIDATOR_FACTORY_BASE_TYPE = exports.KEY_MANAGER_FACTORY_BASE_TYPE = exports.SecureChannelManagerFactory = exports.SECURE_CHANNEL_MANAGER_FACTORY_BASE_TYPE = exports.ENCRYPTION_MANAGER_FACTORY_BASE_TYPE = exports.NoopTrustStoreProvider = exports.TrustStoreProviderFactory = exports.TRUST_STORE_PROVIDER_FACTORY_BASE_TYPE = exports.CertificateManagerFactory = exports.CERTIFICATE_MANAGER_FACTORY_BASE_TYPE = exports.TokenProviderFactory = exports.TOKEN_PROVIDER_FACTORY_BASE_TYPE = exports.TokenVerifierFactory = exports.TOKEN_VERIFIER_FACTORY_BASE_TYPE = exports.TokenIssuerFactory = exports.TOKEN_ISSUER_FACTORY_BASE_TYPE = exports.AuthInjectionStrategyFactory = exports.AUTH_INJECTION_STRATEGY_FACTORY_BASE_TYPE = exports.AuthorizerFactory = exports.AUTHORIZER_FACTORY_BASE_TYPE = void 0;
3
+ exports.ENV_VAR_JWKS_URL = exports.ENV_VAR_JWT_AUDIENCE = exports.ENV_VAR_JWT_ALGORITHM = exports.ENV_VAR_JWT_TRUSTED_ISSUER = exports.CREDENTIAL_PROVIDER_FACTORY_BASE_TYPE = exports.EdDSAEnvelopeSigner = exports.encodeUtf8 = exports.immutableHeaders = exports.frameDigest = exports.decodeBase64Url = exports.canonicalJson = exports.SigningConfigClass = exports.SECURITY_MANAGER_FACTORY_BASE_TYPE = exports.SECURITY_POLICY_FACTORY_BASE_TYPE = exports.KEY_STORE_FACTORY_BASE_TYPE = exports.ATTACHMENT_KEY_VALIDATOR_FACTORY_BASE_TYPE = exports.KEY_MANAGER_FACTORY_BASE_TYPE = exports.SecureChannelManagerFactory = exports.SECURE_CHANNEL_MANAGER_FACTORY_BASE_TYPE = exports.ENCRYPTION_MANAGER_FACTORY_BASE_TYPE = exports.NoopTrustStoreProvider = exports.TrustStoreProviderFactory = exports.TRUST_STORE_PROVIDER_FACTORY_BASE_TYPE = exports.CertificateManagerFactory = exports.CERTIFICATE_MANAGER_FACTORY_BASE_TYPE = exports.TokenProviderFactory = exports.TOKEN_PROVIDER_FACTORY_BASE_TYPE = exports.TokenVerifierFactory = exports.TOKEN_VERIFIER_FACTORY_BASE_TYPE = exports.TokenIssuerFactory = exports.TOKEN_ISSUER_FACTORY_BASE_TYPE = exports.AuthInjectionStrategyFactory = exports.AUTH_INJECTION_STRATEGY_FACTORY_BASE_TYPE = exports.AUTH_PROFILE_ENV_VAR_HMAC_SECRET = exports.AUTH_PROFILE_ENV_VAR_JWT_REVERSE_AUTH_AUDIENCE = exports.AUTH_PROFILE_ENV_VAR_JWT_REVERSE_AUTH_TRUSTED_ISSUER = exports.AUTH_PROFILE_ENV_VAR_TRUSTED_CLIENT_SCOPE = exports.AUTH_PROFILE_ENV_VAR_ENFORCE_TOKEN_SUBJECT_NODE_IDENTITY = exports.AUTH_PROFILE_ENV_VAR_JWKS_URL = exports.AUTH_PROFILE_ENV_VAR_JWT_AUDIENCE = exports.AUTH_PROFILE_ENV_VAR_JWT_ALGORITHM = exports.AUTH_PROFILE_ENV_VAR_JWT_TRUSTED_ISSUER = exports.AUTH_PROFILE_NAME_NOOP = exports.AUTH_PROFILE_NAME_OAUTH2_CALLBACK = exports.AUTH_PROFILE_NAME_OAUTH2_GATED = exports.AUTH_PROFILE_NAME_OAUTH2 = exports.AUTH_PROFILE_NAME_DEFAULT = exports.AuthorizationProfileFactory = exports.AuthorizerFactory = exports.AUTHORIZER_FACTORY_BASE_TYPE = void 0;
4
+ exports.PROFILE_NAME_OPEN = exports.PROFILE_NAME_GATED_CALLBACK = exports.PROFILE_NAME_GATED = exports.PROFILE_NAME_OVERLAY_CALLBACK = exports.PROFILE_NAME_OVERLAY = exports.PROFILE_NAME_STRICT_OVERLAY = exports.ENV_VAR_AUTHORIZATION_PROFILE = exports.ENV_VAR_JWT_REVERSE_AUTH_AUDIENCE = exports.ENV_VAR_JWT_REVERSE_AUTH_TRUSTED_ISSUER = exports.ENV_VAR_HMAC_SECRET = exports.ENV_VAR_DEFAULT_ENCRYPTION_LEVEL = void 0;
4
5
  const tslib_1 = require("tslib");
5
6
  tslib_1.__exportStar(require("./auth/authorizer.js"), exports);
6
7
  tslib_1.__exportStar(require("./auth/auth-identity.js"), exports);
8
+ tslib_1.__exportStar(require("./auth/policy-authorizer.js"), exports);
7
9
  var authorizer_factory_js_1 = require("./auth/authorizer-factory.js");
8
10
  Object.defineProperty(exports, "AUTHORIZER_FACTORY_BASE_TYPE", { enumerable: true, get: function () { return authorizer_factory_js_1.AUTHORIZER_FACTORY_BASE_TYPE; } });
9
11
  Object.defineProperty(exports, "AuthorizerFactory", { enumerable: true, get: function () { return authorizer_factory_js_1.AuthorizerFactory; } });
12
+ var authorization_profile_factory_js_1 = require("./auth/authorization-profile-factory.js");
13
+ Object.defineProperty(exports, "AuthorizationProfileFactory", { enumerable: true, get: function () { return authorization_profile_factory_js_1.AuthorizationProfileFactory; } });
14
+ Object.defineProperty(exports, "AUTH_PROFILE_NAME_DEFAULT", { enumerable: true, get: function () { return authorization_profile_factory_js_1.PROFILE_NAME_DEFAULT; } });
15
+ Object.defineProperty(exports, "AUTH_PROFILE_NAME_OAUTH2", { enumerable: true, get: function () { return authorization_profile_factory_js_1.PROFILE_NAME_OAUTH2; } });
16
+ Object.defineProperty(exports, "AUTH_PROFILE_NAME_OAUTH2_GATED", { enumerable: true, get: function () { return authorization_profile_factory_js_1.PROFILE_NAME_OAUTH2_GATED; } });
17
+ Object.defineProperty(exports, "AUTH_PROFILE_NAME_OAUTH2_CALLBACK", { enumerable: true, get: function () { return authorization_profile_factory_js_1.PROFILE_NAME_OAUTH2_CALLBACK; } });
18
+ Object.defineProperty(exports, "AUTH_PROFILE_NAME_NOOP", { enumerable: true, get: function () { return authorization_profile_factory_js_1.PROFILE_NAME_NOOP; } });
19
+ Object.defineProperty(exports, "AUTH_PROFILE_ENV_VAR_JWT_TRUSTED_ISSUER", { enumerable: true, get: function () { return authorization_profile_factory_js_1.ENV_VAR_JWT_TRUSTED_ISSUER; } });
20
+ Object.defineProperty(exports, "AUTH_PROFILE_ENV_VAR_JWT_ALGORITHM", { enumerable: true, get: function () { return authorization_profile_factory_js_1.ENV_VAR_JWT_ALGORITHM; } });
21
+ Object.defineProperty(exports, "AUTH_PROFILE_ENV_VAR_JWT_AUDIENCE", { enumerable: true, get: function () { return authorization_profile_factory_js_1.ENV_VAR_JWT_AUDIENCE; } });
22
+ Object.defineProperty(exports, "AUTH_PROFILE_ENV_VAR_JWKS_URL", { enumerable: true, get: function () { return authorization_profile_factory_js_1.ENV_VAR_JWKS_URL; } });
23
+ Object.defineProperty(exports, "AUTH_PROFILE_ENV_VAR_ENFORCE_TOKEN_SUBJECT_NODE_IDENTITY", { enumerable: true, get: function () { return authorization_profile_factory_js_1.ENV_VAR_ENFORCE_TOKEN_SUBJECT_NODE_IDENTITY; } });
24
+ Object.defineProperty(exports, "AUTH_PROFILE_ENV_VAR_TRUSTED_CLIENT_SCOPE", { enumerable: true, get: function () { return authorization_profile_factory_js_1.ENV_VAR_TRUSTED_CLIENT_SCOPE; } });
25
+ Object.defineProperty(exports, "AUTH_PROFILE_ENV_VAR_JWT_REVERSE_AUTH_TRUSTED_ISSUER", { enumerable: true, get: function () { return authorization_profile_factory_js_1.ENV_VAR_JWT_REVERSE_AUTH_TRUSTED_ISSUER; } });
26
+ Object.defineProperty(exports, "AUTH_PROFILE_ENV_VAR_JWT_REVERSE_AUTH_AUDIENCE", { enumerable: true, get: function () { return authorization_profile_factory_js_1.ENV_VAR_JWT_REVERSE_AUTH_AUDIENCE; } });
27
+ Object.defineProperty(exports, "AUTH_PROFILE_ENV_VAR_HMAC_SECRET", { enumerable: true, get: function () { return authorization_profile_factory_js_1.ENV_VAR_HMAC_SECRET; } });
10
28
  tslib_1.__exportStar(require("./auth/auth-injection-strategy.js"), exports);
29
+ // Authorization policy exports
30
+ tslib_1.__exportStar(require("./auth/policy/index.js"), exports);
11
31
  var auth_injection_strategy_factory_js_1 = require("./auth/auth-injection-strategy-factory.js");
12
32
  Object.defineProperty(exports, "AUTH_INJECTION_STRATEGY_FACTORY_BASE_TYPE", { enumerable: true, get: function () { return auth_injection_strategy_factory_js_1.AUTH_INJECTION_STRATEGY_FACTORY_BASE_TYPE; } });
13
33
  Object.defineProperty(exports, "AuthInjectionStrategyFactory", { enumerable: true, get: function () { return auth_injection_strategy_factory_js_1.AuthInjectionStrategyFactory; } });
@@ -109,6 +129,7 @@ Object.defineProperty(exports, "ENV_VAR_DEFAULT_ENCRYPTION_LEVEL", { enumerable:
109
129
  Object.defineProperty(exports, "ENV_VAR_HMAC_SECRET", { enumerable: true, get: function () { return node_security_profile_factory_js_1.ENV_VAR_HMAC_SECRET; } });
110
130
  Object.defineProperty(exports, "ENV_VAR_JWT_REVERSE_AUTH_TRUSTED_ISSUER", { enumerable: true, get: function () { return node_security_profile_factory_js_1.ENV_VAR_JWT_REVERSE_AUTH_TRUSTED_ISSUER; } });
111
131
  Object.defineProperty(exports, "ENV_VAR_JWT_REVERSE_AUTH_AUDIENCE", { enumerable: true, get: function () { return node_security_profile_factory_js_1.ENV_VAR_JWT_REVERSE_AUTH_AUDIENCE; } });
132
+ Object.defineProperty(exports, "ENV_VAR_AUTHORIZATION_PROFILE", { enumerable: true, get: function () { return node_security_profile_factory_js_1.ENV_VAR_AUTHORIZATION_PROFILE; } });
112
133
  Object.defineProperty(exports, "PROFILE_NAME_STRICT_OVERLAY", { enumerable: true, get: function () { return node_security_profile_factory_js_1.PROFILE_NAME_STRICT_OVERLAY; } });
113
134
  Object.defineProperty(exports, "PROFILE_NAME_OVERLAY", { enumerable: true, get: function () { return node_security_profile_factory_js_1.PROFILE_NAME_OVERLAY; } });
114
135
  Object.defineProperty(exports, "PROFILE_NAME_OVERLAY_CALLBACK", { enumerable: true, get: function () { return node_security_profile_factory_js_1.PROFILE_NAME_OVERLAY_CALLBACK; } });
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.NodeSecurityProfileFactory = exports.FACTORY_META = exports.PROFILE_NAME_OPEN = exports.PROFILE_NAME_GATED_CALLBACK = exports.PROFILE_NAME_GATED = exports.PROFILE_NAME_OVERLAY_CALLBACK = exports.PROFILE_NAME_OVERLAY = exports.PROFILE_NAME_STRICT_OVERLAY = exports.ENV_VAR_ENFORCE_TOKEN_SUBJECT_NODE_IDENTITY = exports.ENV_VAR_JWT_REVERSE_AUTH_AUDIENCE = exports.ENV_VAR_JWT_REVERSE_AUTH_TRUSTED_ISSUER = exports.ENV_VAR_HMAC_SECRET = exports.ENV_VAR_DEFAULT_ENCRYPTION_LEVEL = exports.ENV_VAR_JWKS_URL = exports.ENV_VAR_JWT_AUDIENCE = exports.ENV_VAR_JWT_ALGORITHM = exports.ENV_VAR_JWT_TRUSTED_ISSUER = void 0;
3
+ exports.NodeSecurityProfileFactory = exports.FACTORY_META = exports.PROFILE_NAME_OPEN = exports.PROFILE_NAME_GATED_CALLBACK = exports.PROFILE_NAME_GATED = exports.PROFILE_NAME_OVERLAY_CALLBACK = exports.PROFILE_NAME_OVERLAY = exports.PROFILE_NAME_STRICT_OVERLAY = exports.ENV_VAR_AUTHORIZATION_PROFILE = exports.ENV_VAR_TRUSTED_CLIENT_SCOPE = exports.ENV_VAR_ENFORCE_TOKEN_SUBJECT_NODE_IDENTITY = exports.ENV_VAR_JWT_REVERSE_AUTH_AUDIENCE = exports.ENV_VAR_JWT_REVERSE_AUTH_TRUSTED_ISSUER = exports.ENV_VAR_HMAC_SECRET = exports.ENV_VAR_DEFAULT_ENCRYPTION_LEVEL = exports.ENV_VAR_JWKS_URL = exports.ENV_VAR_JWT_AUDIENCE = exports.ENV_VAR_JWT_ALGORITHM = exports.ENV_VAR_JWT_TRUSTED_ISSUER = void 0;
4
4
  const factory_1 = require("@naylence/factory");
5
5
  const security_manager_factory_js_1 = require("./security-manager-factory.js");
6
6
  const logging_js_1 = require("../util/logging.js");
@@ -14,14 +14,14 @@ exports.ENV_VAR_HMAC_SECRET = 'FAME_HMAC_SECRET';
14
14
  exports.ENV_VAR_JWT_REVERSE_AUTH_TRUSTED_ISSUER = 'FAME_JWT_REVERSE_AUTH_TRUSTED_ISSUER';
15
15
  exports.ENV_VAR_JWT_REVERSE_AUTH_AUDIENCE = 'FAME_JWT_REVERSE_AUTH_AUDIENCE';
16
16
  exports.ENV_VAR_ENFORCE_TOKEN_SUBJECT_NODE_IDENTITY = 'FAME_ENFORCE_TOKEN_SUBJECT_NODE_IDENTITY';
17
+ exports.ENV_VAR_TRUSTED_CLIENT_SCOPE = 'FAME_TRUSTED_CLIENT_SCOPE';
18
+ exports.ENV_VAR_AUTHORIZATION_PROFILE = 'FAME_AUTHORIZATION_PROFILE';
17
19
  exports.PROFILE_NAME_STRICT_OVERLAY = 'strict-overlay';
18
20
  exports.PROFILE_NAME_OVERLAY = 'overlay';
19
21
  exports.PROFILE_NAME_OVERLAY_CALLBACK = 'overlay-callback';
20
22
  exports.PROFILE_NAME_GATED = 'gated';
21
23
  exports.PROFILE_NAME_GATED_CALLBACK = 'gated-callback';
22
24
  exports.PROFILE_NAME_OPEN = 'open';
23
- const DEFAULT_REVERSE_AUTH_ISSUER = 'reverse-auth.naylence.ai';
24
- const DEFAULT_REVERSE_AUTH_AUDIENCE = 'dev.naylence.ai';
25
25
  const STRICT_OVERLAY_PROFILE = {
26
26
  type: 'DefaultSecurityManager',
27
27
  security_policy: {
@@ -67,12 +67,8 @@ const STRICT_OVERLAY_PROFILE = {
67
67
  },
68
68
  },
69
69
  authorizer: {
70
- type: 'DefaultAuthorizer',
71
- verifier: {
72
- type: 'JWKSJWTTokenVerifier',
73
- jwks_url: factory_1.Expressions.env(exports.ENV_VAR_JWKS_URL),
74
- issuer: factory_1.Expressions.env(exports.ENV_VAR_JWT_TRUSTED_ISSUER),
75
- },
70
+ type: 'AuthorizationProfile',
71
+ profile: factory_1.Expressions.env(exports.ENV_VAR_AUTHORIZATION_PROFILE, 'jwt'),
76
72
  },
77
73
  };
78
74
  const OVERLAY_PROFILE = {
@@ -119,14 +115,8 @@ const OVERLAY_PROFILE = {
119
115
  },
120
116
  },
121
117
  authorizer: {
122
- type: 'OAuth2Authorizer',
123
- issuer: factory_1.Expressions.env(exports.ENV_VAR_JWT_TRUSTED_ISSUER),
124
- required_scopes: ['node.connect'],
125
- require_scope: true,
126
- default_ttl_sec: 3600,
127
- max_ttl_sec: 86400,
128
- algorithm: factory_1.Expressions.env(exports.ENV_VAR_JWT_ALGORITHM, 'RS256'),
129
- audience: factory_1.Expressions.env(exports.ENV_VAR_JWT_AUDIENCE),
118
+ type: 'AuthorizationProfile',
119
+ profile: factory_1.Expressions.env(exports.ENV_VAR_AUTHORIZATION_PROFILE, 'oauth2'),
130
120
  },
131
121
  };
132
122
  const OVERLAY_CALLBACK_PROFILE = {
@@ -173,29 +163,8 @@ const OVERLAY_CALLBACK_PROFILE = {
173
163
  },
174
164
  },
175
165
  authorizer: {
176
- type: 'OAuth2Authorizer',
177
- issuer: factory_1.Expressions.env(exports.ENV_VAR_JWT_REVERSE_AUTH_TRUSTED_ISSUER, DEFAULT_REVERSE_AUTH_ISSUER),
178
- audience: factory_1.Expressions.env(exports.ENV_VAR_JWT_REVERSE_AUTH_AUDIENCE),
179
- require_scope: true,
180
- default_ttl_sec: 3600,
181
- max_ttl_sec: 86400,
182
- reverse_auth_ttl_sec: 86400,
183
- token_verifier_config: {
184
- type: 'JWTTokenVerifier',
185
- algorithm: 'HS256',
186
- hmac_secret: factory_1.Expressions.env(exports.ENV_VAR_HMAC_SECRET),
187
- issuer: factory_1.Expressions.env(exports.ENV_VAR_JWT_REVERSE_AUTH_TRUSTED_ISSUER, DEFAULT_REVERSE_AUTH_ISSUER),
188
- ttl_sec: 86400,
189
- },
190
- token_issuer_config: {
191
- type: 'JWTTokenIssuer',
192
- algorithm: 'HS256',
193
- hmac_secret: factory_1.Expressions.env(exports.ENV_VAR_HMAC_SECRET),
194
- kid: 'hmac-reverse-auth-key',
195
- issuer: factory_1.Expressions.env(exports.ENV_VAR_JWT_REVERSE_AUTH_TRUSTED_ISSUER, DEFAULT_REVERSE_AUTH_ISSUER),
196
- ttl_sec: 86400,
197
- audience: factory_1.Expressions.env(exports.ENV_VAR_JWT_REVERSE_AUTH_AUDIENCE, DEFAULT_REVERSE_AUTH_AUDIENCE),
198
- },
166
+ type: 'AuthorizationProfile',
167
+ profile: factory_1.Expressions.env(exports.ENV_VAR_AUTHORIZATION_PROFILE, 'oauth2-callback'),
199
168
  },
200
169
  };
201
170
  const GATED_PROFILE = {
@@ -241,15 +210,8 @@ const GATED_PROFILE = {
241
210
  },
242
211
  },
243
212
  authorizer: {
244
- type: 'OAuth2Authorizer',
245
- issuer: factory_1.Expressions.env(exports.ENV_VAR_JWT_TRUSTED_ISSUER),
246
- required_scopes: ['node.connect'],
247
- require_scope: true,
248
- default_ttl_sec: 3600,
249
- max_ttl_sec: 86400,
250
- algorithm: factory_1.Expressions.env(exports.ENV_VAR_JWT_ALGORITHM, 'RS256'),
251
- audience: factory_1.Expressions.env(exports.ENV_VAR_JWT_AUDIENCE),
252
- enforce_token_subject_node_identity: factory_1.Expressions.env(exports.ENV_VAR_ENFORCE_TOKEN_SUBJECT_NODE_IDENTITY, 'false'),
213
+ type: 'AuthorizationProfile',
214
+ profile: factory_1.Expressions.env(exports.ENV_VAR_AUTHORIZATION_PROFILE, 'oauth2-gated'),
253
215
  },
254
216
  };
255
217
  const GATED_CALLBACK_PROFILE = {
@@ -295,29 +257,8 @@ const GATED_CALLBACK_PROFILE = {
295
257
  },
296
258
  },
297
259
  authorizer: {
298
- type: 'OAuth2Authorizer',
299
- issuer: factory_1.Expressions.env(exports.ENV_VAR_JWT_REVERSE_AUTH_TRUSTED_ISSUER, DEFAULT_REVERSE_AUTH_ISSUER),
300
- audience: factory_1.Expressions.env(exports.ENV_VAR_JWT_REVERSE_AUTH_AUDIENCE),
301
- require_scope: true,
302
- default_ttl_sec: 3600,
303
- max_ttl_sec: 86400,
304
- reverse_auth_ttl_sec: 86400,
305
- token_verifier_config: {
306
- type: 'JWTTokenVerifier',
307
- algorithm: 'HS256',
308
- hmac_secret: factory_1.Expressions.env(exports.ENV_VAR_HMAC_SECRET),
309
- issuer: factory_1.Expressions.env(exports.ENV_VAR_JWT_REVERSE_AUTH_TRUSTED_ISSUER, DEFAULT_REVERSE_AUTH_ISSUER),
310
- ttl_sec: 86400,
311
- },
312
- token_issuer_config: {
313
- type: 'JWTTokenIssuer',
314
- algorithm: 'HS256',
315
- hmac_secret: factory_1.Expressions.env(exports.ENV_VAR_HMAC_SECRET),
316
- kid: 'hmac-reverse-auth-key',
317
- issuer: factory_1.Expressions.env(exports.ENV_VAR_JWT_REVERSE_AUTH_TRUSTED_ISSUER, DEFAULT_REVERSE_AUTH_ISSUER),
318
- ttl_sec: 86400,
319
- audience: factory_1.Expressions.env(exports.ENV_VAR_JWT_REVERSE_AUTH_AUDIENCE, DEFAULT_REVERSE_AUTH_AUDIENCE),
320
- },
260
+ type: 'AuthorizationProfile',
261
+ profile: factory_1.Expressions.env(exports.ENV_VAR_AUTHORIZATION_PROFILE, 'oauth2-callback'),
321
262
  },
322
263
  };
323
264
  const OPEN_PROFILE = {
@@ -326,7 +267,8 @@ const OPEN_PROFILE = {
326
267
  type: 'NoSecurityPolicy',
327
268
  },
328
269
  authorizer: {
329
- type: 'NoopAuthorizer',
270
+ type: 'AuthorizationProfile',
271
+ profile: factory_1.Expressions.env(exports.ENV_VAR_AUTHORIZATION_PROFILE, 'noop'),
330
272
  },
331
273
  };
332
274
  const PROFILE_MAP = {
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.RouterState = exports.ForwardPeer = exports.ForwardChild = exports.DeliverLocal = exports.ForwardUp = exports.Drop = void 0;
3
+ exports.RouterState = exports.Deny = exports.ForwardPeer = exports.ForwardChild = exports.DeliverLocal = exports.ForwardUp = exports.Drop = void 0;
4
+ exports.mapRoutingActionToAuthorizationAction = mapRoutingActionToAuthorizationAction;
4
5
  exports.emitDeliveryNack = emitDeliveryNack;
5
6
  const core_1 = require("@naylence/core");
6
7
  const errors_js_1 = require("../errors/errors.js");
@@ -99,6 +100,71 @@ class ForwardPeer {
99
100
  }
100
101
  }
101
102
  exports.ForwardPeer = ForwardPeer;
103
+ /**
104
+ * RoutingAction that denies an envelope due to authorization failure.
105
+ *
106
+ * Emits an opaque NO_ROUTE NACK on wire (by default) to avoid leaking
107
+ * route existence, while logging the true denial reason internally.
108
+ */
109
+ class Deny {
110
+ constructor(options) {
111
+ this.options = options;
112
+ }
113
+ async execute(envelope, router, state, context) {
114
+ const { internalReason, deniedAction, matchedRule, context: extraContext, disclosure = 'opaque', } = this.options;
115
+ // Log detailed denial internally
116
+ logger.warning('route_authorization_denied', {
117
+ envp_id: envelope.id,
118
+ frame_type: envelope.frame?.type ?? null,
119
+ to: envelope.to?.toString() ?? null,
120
+ internal_reason: internalReason,
121
+ denied_action: deniedAction ?? null,
122
+ matched_rule: matchedRule ?? null,
123
+ origin_type: context?.originType ?? null,
124
+ ...extraContext,
125
+ });
126
+ // Emit opaque NACK on wire (or verbose if configured)
127
+ const wireCode = disclosure === 'verbose' ? 'UNAUTHORIZED_ROUTE' : 'NO_ROUTE';
128
+ await emitDeliveryNack(envelope, router, state, wireCode, context ?? undefined);
129
+ }
130
+ }
131
+ exports.Deny = Deny;
132
+ /**
133
+ * Maps a RoutingAction instance to an authorization action token.
134
+ *
135
+ * This function uses instanceof checks to determine the action type,
136
+ * avoiding the need to expose action objects to the authorizer.
137
+ *
138
+ * For unknown/custom RoutingAction types, returns null. Callers should
139
+ * treat null as "deny by default" for security (unknown actions are not
140
+ * authorized).
141
+ *
142
+ * @param action - The RoutingAction instance to map
143
+ * @returns The authorization action token, or null for terminal/unknown actions
144
+ */
145
+ function mapRoutingActionToAuthorizationAction(action) {
146
+ if (action instanceof ForwardUp) {
147
+ return 'ForwardUpstream';
148
+ }
149
+ if (action instanceof ForwardChild) {
150
+ return 'ForwardDownstream';
151
+ }
152
+ if (action instanceof ForwardPeer) {
153
+ return 'ForwardPeer';
154
+ }
155
+ if (action instanceof DeliverLocal) {
156
+ return 'DeliverLocal';
157
+ }
158
+ // Drop and Deny are terminal actions that don't need authorization
159
+ if (action instanceof Drop || action instanceof Deny) {
160
+ return null;
161
+ }
162
+ // Unknown RoutingAction: return null, caller should deny by default
163
+ logger.warning('unknown_routing_action_for_authorization', {
164
+ action_type: action?.constructor?.name ?? 'unknown',
165
+ });
166
+ return null;
167
+ }
102
168
  class RouterState {
103
169
  constructor(options) {
104
170
  const normalized = normalizeRouterStateOptions(options);
@@ -281,8 +281,11 @@ class Sentinel extends node_js_1.FameNode {
281
281
  }
282
282
  }
283
283
  const state = this.buildRouterState();
284
- const action = await this.routingPolicy.decide(processedEnvelope, state, context);
285
- await action.execute(processedEnvelope, this, state, context);
284
+ let action = await this.routingPolicy.decide(processedEnvelope, state, context);
285
+ // Dispatch onRoutingActionSelected hook to allow authorization/replacement
286
+ // The hook must return the action to execute; null/undefined/throw => Drop
287
+ const actionToExecute = await this.dispatchRoutingActionSelected(processedEnvelope, action, state, context);
288
+ await actionToExecute.execute(processedEnvelope, this, state, context);
286
289
  }
287
290
  async forwardToRoute(nextSegment, envelope, context) {
288
291
  if (this.originMatches(context, nextSegment, core_1.DeliveryOriginType.DOWNSTREAM)) {
@@ -828,6 +831,47 @@ class Sentinel extends node_js_1.FameNode {
828
831
  });
829
832
  }
830
833
  }
834
+ /**
835
+ * Dispatches the onRoutingActionSelected event to all event listeners.
836
+ *
837
+ * This allows listeners (like DefaultSecurityManager) to authorize
838
+ * routing actions and optionally replace them with Deny actions.
839
+ *
840
+ * The hook must return the RoutingAction to execute. If a listener returns
841
+ * null, undefined, or throws, the router will execute a Drop action.
842
+ *
843
+ * @param envelope - The envelope being routed
844
+ * @param selected - The RoutingAction selected by the routing policy
845
+ * @param state - The current router state
846
+ * @param context - Optional delivery context
847
+ * @returns The RoutingAction to execute (never null/undefined)
848
+ */
849
+ async dispatchRoutingActionSelected(envelope, selected, state, context) {
850
+ let currentAction = selected;
851
+ for (const listener of this.eventListeners) {
852
+ if (typeof listener.onRoutingActionSelected !== 'function') {
853
+ continue;
854
+ }
855
+ try {
856
+ const result = await listener.onRoutingActionSelected(this, envelope, currentAction, state, context);
857
+ // null/undefined => treat as denial, execute Drop
858
+ if (result == null) {
859
+ return new router_js_1.Drop();
860
+ }
861
+ // Update current action for next listener in chain
862
+ currentAction = result;
863
+ }
864
+ catch (error) {
865
+ // Hook threw => treat as denial, execute Drop
866
+ logger.warning('routing_action_hook_error', {
867
+ envp_id: envelope.id,
868
+ error: error instanceof Error ? error.message : String(error),
869
+ });
870
+ return new router_js_1.Drop();
871
+ }
872
+ }
873
+ return currentAction;
874
+ }
831
875
  static async aserve(options = {}) {
832
876
  const { logLevel, rootConfig, config, node = null, fabric: providedFabric = null, signals = ['SIGINT', 'SIGTERM'], signal, ...fabricOptions } = options;
833
877
  const resolvedLevel = normalizeServeLogLevel(logLevel) ?? logging_js_1.LogLevel.INFO;
@@ -45,6 +45,8 @@ const NODE_ONLY_FACTORY_MODULES = new Set([
45
45
  './connector/websocket-listener-factory.js',
46
46
  './telemetry/open-telemetry-trace-emitter-factory.js',
47
47
  './security/credential/prompt-credential-provider-factory.js',
48
+ './security/auth/default-policy-authorizer-factory.js',
49
+ './security/auth/policy/local-file-authorization-policy-source-factory.js',
48
50
  ]);
49
51
  const BROWSER_ONLY_FACTORY_MODULES = new Set([
50
52
  './security/auth/oauth2-pkce-token-provider-factory.js',
@@ -1,10 +1,10 @@
1
1
  "use strict";
2
2
  // This file is auto-generated during build - do not edit manually
3
- // Generated from package.json version: 0.3.21
3
+ // Generated from package.json version: 0.4.1
4
4
  Object.defineProperty(exports, "__esModule", { value: true });
5
5
  exports.VERSION = void 0;
6
6
  /**
7
7
  * The package version, injected at build time.
8
8
  * @internal
9
9
  */
10
- exports.VERSION = '0.3.21';
10
+ exports.VERSION = '0.4.1';
@@ -27,8 +27,10 @@ export const MODULES = [
27
27
  "./node/node-identity-policy-profile-factory.js",
28
28
  "./node/token-subject-node-identity-policy-factory.js",
29
29
  "./placement/static-node-placement-strategy-factory.js",
30
+ "./security/auth/authorization-profile-factory.js",
30
31
  "./security/auth/bearer-token-header-auth-injection-strategy-factory.js",
31
32
  "./security/auth/default-authorizer-factory.js",
33
+ "./security/auth/default-policy-authorizer-factory.js",
32
34
  "./security/auth/jwks-jwt-token-verifier-factory.js",
33
35
  "./security/auth/jwt-token-issuer-factory.js",
34
36
  "./security/auth/jwt-token-verifier-factory.js",
@@ -40,6 +42,8 @@ export const MODULES = [
40
42
  "./security/auth/oauth2-authorizer-factory.js",
41
43
  "./security/auth/oauth2-client-credentials-token-provider-factory.js",
42
44
  "./security/auth/oauth2-pkce-token-provider-factory.js",
45
+ "./security/auth/policy/basic-authorization-policy-factory.js",
46
+ "./security/auth/policy/local-file-authorization-policy-source-factory.js",
43
47
  "./security/auth/query-param-auth-injection-strategy-factory.js",
44
48
  "./security/auth/shared-secret-authorizer-factory.js",
45
49
  "./security/auth/shared-secret-token-provider-factory.js",
@@ -106,8 +110,10 @@ export const MODULE_LOADERS = {
106
110
  "./node/node-identity-policy-profile-factory.js": () => import("./node/node-identity-policy-profile-factory.js"),
107
111
  "./node/token-subject-node-identity-policy-factory.js": () => import("./node/token-subject-node-identity-policy-factory.js"),
108
112
  "./placement/static-node-placement-strategy-factory.js": () => import("./placement/static-node-placement-strategy-factory.js"),
113
+ "./security/auth/authorization-profile-factory.js": () => import("./security/auth/authorization-profile-factory.js"),
109
114
  "./security/auth/bearer-token-header-auth-injection-strategy-factory.js": () => import("./security/auth/bearer-token-header-auth-injection-strategy-factory.js"),
110
115
  "./security/auth/default-authorizer-factory.js": () => import("./security/auth/default-authorizer-factory.js"),
116
+ "./security/auth/default-policy-authorizer-factory.js": () => import(/* webpackIgnore: true */ /* @vite-ignore */ "./security/auth/default-policy-authorizer-factory.js"),
111
117
  "./security/auth/jwks-jwt-token-verifier-factory.js": () => import("./security/auth/jwks-jwt-token-verifier-factory.js"),
112
118
  "./security/auth/jwt-token-issuer-factory.js": () => import("./security/auth/jwt-token-issuer-factory.js"),
113
119
  "./security/auth/jwt-token-verifier-factory.js": () => import("./security/auth/jwt-token-verifier-factory.js"),
@@ -119,6 +125,8 @@ export const MODULE_LOADERS = {
119
125
  "./security/auth/oauth2-authorizer-factory.js": () => import("./security/auth/oauth2-authorizer-factory.js"),
120
126
  "./security/auth/oauth2-client-credentials-token-provider-factory.js": () => import("./security/auth/oauth2-client-credentials-token-provider-factory.js"),
121
127
  "./security/auth/oauth2-pkce-token-provider-factory.js": () => import("./security/auth/oauth2-pkce-token-provider-factory.js"),
128
+ "./security/auth/policy/basic-authorization-policy-factory.js": () => import("./security/auth/policy/basic-authorization-policy-factory.js"),
129
+ "./security/auth/policy/local-file-authorization-policy-source-factory.js": () => import(/* webpackIgnore: true */ /* @vite-ignore */ "./security/auth/policy/local-file-authorization-policy-source-factory.js"),
122
130
  "./security/auth/query-param-auth-injection-strategy-factory.js": () => import("./security/auth/query-param-auth-injection-strategy-factory.js"),
123
131
  "./security/auth/shared-secret-authorizer-factory.js": () => import("./security/auth/shared-secret-authorizer-factory.js"),
124
132
  "./security/auth/shared-secret-token-provider-factory.js": () => import("./security/auth/shared-secret-token-provider-factory.js"),
@@ -45,6 +45,10 @@ export class BaseNodeEventListener {
45
45
  // Default implementation passes envelope through unchanged
46
46
  return envelope;
47
47
  }
48
+ async onRoutingActionSelected(_node, _envelope, selected, _state, _context) {
49
+ // Default implementation returns the selected action unchanged
50
+ return selected;
51
+ }
48
52
  async onForwardUpstream(_node, envelope, _context) {
49
53
  // Default implementation passes envelope through unchanged
50
54
  return envelope;
@@ -0,0 +1,161 @@
1
+ import { Expressions } from '@naylence/factory';
2
+ import { getLogger } from '../../util/logging.js';
3
+ import { AUTHORIZER_FACTORY_BASE_TYPE, AuthorizerFactory, } from './authorizer-factory.js';
4
+ const logger = getLogger('naylence.fame.security.auth.authorization_profile_factory');
5
+ export const PROFILE_NAME_DEFAULT = 'jwt';
6
+ export const PROFILE_NAME_OAUTH2 = 'oauth2';
7
+ export const PROFILE_NAME_OAUTH2_GATED = 'oauth2-gated';
8
+ export const PROFILE_NAME_OAUTH2_CALLBACK = 'oauth2-callback';
9
+ export const PROFILE_NAME_NOOP = 'noop';
10
+ export const ENV_VAR_JWT_TRUSTED_ISSUER = 'FAME_JWT_TRUSTED_ISSUER';
11
+ export const ENV_VAR_JWT_ALGORITHM = 'FAME_JWT_ALGORITHM';
12
+ export const ENV_VAR_JWT_AUDIENCE = 'FAME_JWT_AUDIENCE';
13
+ export const ENV_VAR_JWKS_URL = 'FAME_JWKS_URL';
14
+ export const ENV_VAR_ENFORCE_TOKEN_SUBJECT_NODE_IDENTITY = 'FAME_ENFORCE_TOKEN_SUBJECT_NODE_IDENTITY';
15
+ export const ENV_VAR_TRUSTED_CLIENT_SCOPE = 'FAME_TRUSTED_CLIENT_SCOPE';
16
+ export const ENV_VAR_JWT_REVERSE_AUTH_TRUSTED_ISSUER = 'FAME_JWT_REVERSE_AUTH_TRUSTED_ISSUER';
17
+ export const ENV_VAR_JWT_REVERSE_AUTH_AUDIENCE = 'FAME_JWT_REVERSE_AUTH_AUDIENCE';
18
+ export const ENV_VAR_HMAC_SECRET = 'FAME_HMAC_SECRET';
19
+ const DEFAULT_REVERSE_AUTH_ISSUER = 'reverse-auth.naylence.ai';
20
+ const DEFAULT_REVERSE_AUTH_AUDIENCE = 'dev.naylence.ai';
21
+ const DEFAULT_PROFILE = {
22
+ type: 'DefaultAuthorizer',
23
+ verifier: {
24
+ type: 'JWKSJWTTokenVerifier',
25
+ jwks_url: Expressions.env(ENV_VAR_JWKS_URL),
26
+ issuer: Expressions.env(ENV_VAR_JWT_TRUSTED_ISSUER),
27
+ },
28
+ };
29
+ const OAUTH2_PROFILE = {
30
+ type: 'OAuth2Authorizer',
31
+ issuer: Expressions.env(ENV_VAR_JWT_TRUSTED_ISSUER),
32
+ required_scopes: ['node.connect'],
33
+ require_scope: true,
34
+ default_ttl_sec: 3600,
35
+ max_ttl_sec: 86400,
36
+ algorithm: Expressions.env(ENV_VAR_JWT_ALGORITHM, 'RS256'),
37
+ audience: Expressions.env(ENV_VAR_JWT_AUDIENCE),
38
+ };
39
+ const OAUTH2_GATED_PROFILE = {
40
+ ...OAUTH2_PROFILE,
41
+ enforce_token_subject_node_identity: Expressions.env(ENV_VAR_ENFORCE_TOKEN_SUBJECT_NODE_IDENTITY, 'false'),
42
+ trusted_client_scope: Expressions.env(ENV_VAR_TRUSTED_CLIENT_SCOPE, 'node.trusted'),
43
+ };
44
+ const OAUTH2_CALLBACK_PROFILE = {
45
+ type: 'OAuth2Authorizer',
46
+ issuer: Expressions.env(ENV_VAR_JWT_REVERSE_AUTH_TRUSTED_ISSUER, DEFAULT_REVERSE_AUTH_ISSUER),
47
+ audience: Expressions.env(ENV_VAR_JWT_REVERSE_AUTH_AUDIENCE),
48
+ require_scope: true,
49
+ default_ttl_sec: 3600,
50
+ max_ttl_sec: 86400,
51
+ reverse_auth_ttl_sec: 86400,
52
+ token_verifier_config: {
53
+ type: 'JWTTokenVerifier',
54
+ algorithm: 'HS256',
55
+ hmac_secret: Expressions.env(ENV_VAR_HMAC_SECRET),
56
+ issuer: Expressions.env(ENV_VAR_JWT_REVERSE_AUTH_TRUSTED_ISSUER, DEFAULT_REVERSE_AUTH_ISSUER),
57
+ ttl_sec: 86400,
58
+ },
59
+ token_issuer_config: {
60
+ type: 'JWTTokenIssuer',
61
+ algorithm: 'HS256',
62
+ hmac_secret: Expressions.env(ENV_VAR_HMAC_SECRET),
63
+ kid: 'hmac-reverse-auth-key',
64
+ issuer: Expressions.env(ENV_VAR_JWT_REVERSE_AUTH_TRUSTED_ISSUER, DEFAULT_REVERSE_AUTH_ISSUER),
65
+ ttl_sec: 86400,
66
+ audience: Expressions.env(ENV_VAR_JWT_REVERSE_AUTH_AUDIENCE, DEFAULT_REVERSE_AUTH_AUDIENCE),
67
+ },
68
+ };
69
+ const NOOP_PROFILE = {
70
+ type: 'NoopAuthorizer',
71
+ };
72
+ const PROFILE_MAP = {
73
+ [PROFILE_NAME_DEFAULT]: DEFAULT_PROFILE,
74
+ [PROFILE_NAME_OAUTH2]: OAUTH2_PROFILE,
75
+ [PROFILE_NAME_OAUTH2_GATED]: OAUTH2_GATED_PROFILE,
76
+ [PROFILE_NAME_OAUTH2_CALLBACK]: OAUTH2_CALLBACK_PROFILE,
77
+ [PROFILE_NAME_NOOP]: NOOP_PROFILE,
78
+ };
79
+ const PROFILE_ALIASES = {
80
+ jwt: PROFILE_NAME_DEFAULT,
81
+ jwks: PROFILE_NAME_DEFAULT,
82
+ default: PROFILE_NAME_DEFAULT,
83
+ oauth2: PROFILE_NAME_OAUTH2,
84
+ oidc: PROFILE_NAME_OAUTH2,
85
+ 'oauth2-gated': PROFILE_NAME_OAUTH2_GATED,
86
+ oauth2_gated: PROFILE_NAME_OAUTH2_GATED,
87
+ 'oauth2-callback': PROFILE_NAME_OAUTH2_CALLBACK,
88
+ oauth2_callback: PROFILE_NAME_OAUTH2_CALLBACK,
89
+ 'reverse-auth': PROFILE_NAME_OAUTH2_CALLBACK,
90
+ noop: PROFILE_NAME_NOOP,
91
+ 'no-op': PROFILE_NAME_NOOP,
92
+ no_op: PROFILE_NAME_NOOP,
93
+ };
94
+ export const FACTORY_META = {
95
+ base: AUTHORIZER_FACTORY_BASE_TYPE,
96
+ key: 'AuthorizationProfile',
97
+ };
98
+ export class AuthorizationProfileFactory extends AuthorizerFactory {
99
+ constructor() {
100
+ super(...arguments);
101
+ this.type = 'AuthorizationProfile';
102
+ }
103
+ async create(config, ...factoryArgs) {
104
+ const normalized = normalizeConfig(config);
105
+ const profileConfig = resolveProfileConfig(normalized.profile);
106
+ logger.debug('enabling_authorization_profile', {
107
+ profile: normalized.profile,
108
+ });
109
+ const authorizer = await AuthorizerFactory.createAuthorizer(profileConfig, { factoryArgs });
110
+ if (!authorizer) {
111
+ throw new Error(`Failed to create authorizer for profile: ${normalized.profile}`);
112
+ }
113
+ return authorizer;
114
+ }
115
+ }
116
+ function normalizeConfig(config) {
117
+ if (!config) {
118
+ return { profile: PROFILE_NAME_OAUTH2 };
119
+ }
120
+ const candidate = config;
121
+ const profileValue = resolveProfileName(candidate);
122
+ const canonicalProfile = canonicalizeProfileName(profileValue);
123
+ candidate.profile = canonicalProfile;
124
+ return { profile: canonicalProfile };
125
+ }
126
+ function resolveProfileName(candidate) {
127
+ const direct = coerceProfileString(candidate.profile);
128
+ if (direct) {
129
+ return direct;
130
+ }
131
+ const legacyKeys = ['profile_name', 'profileName'];
132
+ for (const legacyKey of legacyKeys) {
133
+ const legacyValue = coerceProfileString(candidate[legacyKey]);
134
+ if (legacyValue) {
135
+ return legacyValue;
136
+ }
137
+ }
138
+ return PROFILE_NAME_OAUTH2;
139
+ }
140
+ function coerceProfileString(value) {
141
+ if (typeof value !== 'string') {
142
+ return null;
143
+ }
144
+ const trimmed = value.trim();
145
+ return trimmed.length > 0 ? trimmed : null;
146
+ }
147
+ function canonicalizeProfileName(value) {
148
+ const normalized = value.replace(/[\s_]+/g, '-').toLowerCase();
149
+ return PROFILE_ALIASES[normalized] ?? normalized;
150
+ }
151
+ function resolveProfileConfig(profileName) {
152
+ const profile = PROFILE_MAP[profileName];
153
+ if (!profile) {
154
+ throw new Error(`Unknown authorization profile: ${profileName}`);
155
+ }
156
+ return deepClone(profile);
157
+ }
158
+ function deepClone(value) {
159
+ return JSON.parse(JSON.stringify(value));
160
+ }
161
+ export default AuthorizationProfileFactory;