@naylence/runtime 0.3.21 → 0.3.22

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.
@@ -2,10 +2,12 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.DefaultNodeIdentityPolicy = void 0;
4
4
  const core_1 = require("@naylence/core");
5
- const token_provider_factory_js_1 = require("../security/auth/token-provider-factory.js");
6
- const token_provider_js_1 = require("../security/auth/token-provider.js");
7
- const logging_js_1 = require("../util/logging.js");
8
- const logger = (0, logging_js_1.getLogger)('naylence.fame.node.default_node_identity_policy');
5
+ /**
6
+ * Default node identity policy that preserves the current node ID.
7
+ *
8
+ * This policy does NOT derive identity from tokens or grants.
9
+ * For token-subject-based identity, use TokenSubjectNodeIdentityPolicy.
10
+ */
9
11
  class DefaultNodeIdentityPolicy {
10
12
  async resolveInitialNodeId(context) {
11
13
  if (context.configuredId) {
@@ -17,44 +19,10 @@ class DefaultNodeIdentityPolicy {
17
19
  return await (0, core_1.generateIdAsync)({ mode: 'fingerprint' });
18
20
  }
19
21
  async resolveAdmissionNodeId(context) {
20
- // Try to extract identity from grants first
21
- if (context.grants && context.grants.length > 0) {
22
- for (const grant of context.grants) {
23
- try {
24
- const auth = grant.auth;
25
- if (!auth) {
26
- continue;
27
- }
28
- const tokenProviderConfig = (auth.tokenProvider ??
29
- auth.token_provider);
30
- if (!tokenProviderConfig ||
31
- typeof tokenProviderConfig.type !== 'string') {
32
- continue;
33
- }
34
- const provider = await token_provider_factory_js_1.TokenProviderFactory.createTokenProvider(tokenProviderConfig);
35
- if ((0, token_provider_js_1.isIdentityExposingTokenProvider)(provider)) {
36
- const identity = await provider.getIdentity();
37
- if (identity && identity.subject) {
38
- logger.debug('identity_extracted_from_grant', {
39
- identity_id: identity.subject,
40
- grant_type: grant.type,
41
- });
42
- return identity.subject;
43
- }
44
- }
45
- }
46
- catch (error) {
47
- logger.warning('identity_extraction_failed', {
48
- error: error instanceof Error ? error.message : String(error),
49
- grant_type: grant.type,
50
- });
51
- }
52
- }
22
+ if (context.currentNodeId) {
23
+ return context.currentNodeId;
53
24
  }
54
- if (!context.currentNodeId) {
55
- return await (0, core_1.generateIdAsync)({ mode: 'fingerprint' });
56
- }
57
- return context.currentNodeId;
25
+ return await (0, core_1.generateIdAsync)({ mode: 'fingerprint' });
58
26
  }
59
27
  }
60
28
  exports.DefaultNodeIdentityPolicy = DefaultNodeIdentityPolicy;
@@ -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.3.22
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.3.22';
@@ -1,8 +1,10 @@
1
1
  import { generateIdAsync } from '@naylence/core';
2
- import { TokenProviderFactory } from '../security/auth/token-provider-factory.js';
3
- import { isIdentityExposingTokenProvider } from '../security/auth/token-provider.js';
4
- import { getLogger } from '../util/logging.js';
5
- const logger = getLogger('naylence.fame.node.default_node_identity_policy');
2
+ /**
3
+ * Default node identity policy that preserves the current node ID.
4
+ *
5
+ * This policy does NOT derive identity from tokens or grants.
6
+ * For token-subject-based identity, use TokenSubjectNodeIdentityPolicy.
7
+ */
6
8
  export class DefaultNodeIdentityPolicy {
7
9
  async resolveInitialNodeId(context) {
8
10
  if (context.configuredId) {
@@ -14,43 +16,9 @@ export class DefaultNodeIdentityPolicy {
14
16
  return await generateIdAsync({ mode: 'fingerprint' });
15
17
  }
16
18
  async resolveAdmissionNodeId(context) {
17
- // Try to extract identity from grants first
18
- if (context.grants && context.grants.length > 0) {
19
- for (const grant of context.grants) {
20
- try {
21
- const auth = grant.auth;
22
- if (!auth) {
23
- continue;
24
- }
25
- const tokenProviderConfig = (auth.tokenProvider ??
26
- auth.token_provider);
27
- if (!tokenProviderConfig ||
28
- typeof tokenProviderConfig.type !== 'string') {
29
- continue;
30
- }
31
- const provider = await TokenProviderFactory.createTokenProvider(tokenProviderConfig);
32
- if (isIdentityExposingTokenProvider(provider)) {
33
- const identity = await provider.getIdentity();
34
- if (identity && identity.subject) {
35
- logger.debug('identity_extracted_from_grant', {
36
- identity_id: identity.subject,
37
- grant_type: grant.type,
38
- });
39
- return identity.subject;
40
- }
41
- }
42
- }
43
- catch (error) {
44
- logger.warning('identity_extraction_failed', {
45
- error: error instanceof Error ? error.message : String(error),
46
- grant_type: grant.type,
47
- });
48
- }
49
- }
19
+ if (context.currentNodeId) {
20
+ return context.currentNodeId;
50
21
  }
51
- if (!context.currentNodeId) {
52
- return await generateIdAsync({ mode: 'fingerprint' });
53
- }
54
- return context.currentNodeId;
22
+ return await generateIdAsync({ mode: 'fingerprint' });
55
23
  }
56
24
  }
@@ -1,7 +1,7 @@
1
1
  // This file is auto-generated during build - do not edit manually
2
- // Generated from package.json version: 0.3.21
2
+ // Generated from package.json version: 0.3.22
3
3
  /**
4
4
  * The package version, injected at build time.
5
5
  * @internal
6
6
  */
7
- export const VERSION = '0.3.21';
7
+ export const VERSION = '0.3.22';