@nextera.one/axis-server-sdk 2.3.8 → 2.3.10

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.
@@ -1,4 +1,4 @@
1
- export { n as AccessProfileResolverSensor, $ as BodyBudgetSensor, a2 as CapabilityEnforcementSensor, a7 as ChunkHashSensor, aa as EntropySensor, ac as ExecutionTimeoutSensor, ae as FrameBudgetSensor, af as FrameHeaderSanitySensor, ag as HeaderTLVLimitSensor, ak as IntentAllowlistSensor, an as IntentRegistrySensor, ap as LawEvaluationSensor, av as ProofPresenceSensor, aw as ProtocolStrictSensor, ay as ReceiptPolicySensor, aD as RiskGateSensor, aE as RiskGateSensorOptions, aG as RiskSignalCollector, aI as SchemaValidationSensor, aK as StreamScopeSensor, aL as TLVParseSensor, aO as TickAuthCapsuleRef, aP as TickAuthSensor, aQ as TickAuthSensorOptions, aR as TickAuthVerifier, b0 as TpsSensor, b1 as TpsSensorOptions, b2 as VarintHardeningSensor } from '../index-Bdahn8mq.mjs';
1
+ export { n as AccessProfileResolverSensor, $ as BodyBudgetSensor, a2 as CapabilityEnforcementSensor, a7 as ChunkHashSensor, aa as EntropySensor, ac as ExecutionTimeoutSensor, ae as FrameBudgetSensor, af as FrameHeaderSanitySensor, ag as HeaderTLVLimitSensor, ak as IntentAllowlistSensor, an as IntentRegistrySensor, ap as LawArticlePresenceMode, aq as LawArticlePresenceSensor, ar as LawArticlePresenceSensorOptions, as as LawEvaluationSensor, ay as ProofPresenceSensor, az as ProtocolStrictSensor, aB as ReceiptPolicySensor, aG as RiskGateSensor, aH as RiskGateSensorOptions, aJ as RiskSignalCollector, aL as SchemaValidationSensor, aN as StreamScopeSensor, aO as TLVParseSensor, aR as TickAuthCapsuleRef, aS as TickAuthSensor, aT as TickAuthSensorOptions, aU as TickAuthVerifier, b3 as TpsSensor, b4 as TpsSensorOptions, b5 as VarintHardeningSensor } from '../index-Bquulp8S.mjs';
2
2
  import '../axis-sensor-BLUemDiZ.mjs';
3
3
  import 'zod';
4
4
  import '@nextera.one/axis-protocol';
@@ -1,4 +1,4 @@
1
- export { n as AccessProfileResolverSensor, $ as BodyBudgetSensor, a2 as CapabilityEnforcementSensor, a7 as ChunkHashSensor, aa as EntropySensor, ac as ExecutionTimeoutSensor, ae as FrameBudgetSensor, af as FrameHeaderSanitySensor, ag as HeaderTLVLimitSensor, ak as IntentAllowlistSensor, an as IntentRegistrySensor, ap as LawEvaluationSensor, av as ProofPresenceSensor, aw as ProtocolStrictSensor, ay as ReceiptPolicySensor, aD as RiskGateSensor, aE as RiskGateSensorOptions, aG as RiskSignalCollector, aI as SchemaValidationSensor, aK as StreamScopeSensor, aL as TLVParseSensor, aO as TickAuthCapsuleRef, aP as TickAuthSensor, aQ as TickAuthSensorOptions, aR as TickAuthVerifier, b0 as TpsSensor, b1 as TpsSensorOptions, b2 as VarintHardeningSensor } from '../index-DRnTsYrk.js';
1
+ export { n as AccessProfileResolverSensor, $ as BodyBudgetSensor, a2 as CapabilityEnforcementSensor, a7 as ChunkHashSensor, aa as EntropySensor, ac as ExecutionTimeoutSensor, ae as FrameBudgetSensor, af as FrameHeaderSanitySensor, ag as HeaderTLVLimitSensor, ak as IntentAllowlistSensor, an as IntentRegistrySensor, ap as LawArticlePresenceMode, aq as LawArticlePresenceSensor, ar as LawArticlePresenceSensorOptions, as as LawEvaluationSensor, ay as ProofPresenceSensor, az as ProtocolStrictSensor, aB as ReceiptPolicySensor, aG as RiskGateSensor, aH as RiskGateSensorOptions, aJ as RiskSignalCollector, aL as SchemaValidationSensor, aN as StreamScopeSensor, aO as TLVParseSensor, aR as TickAuthCapsuleRef, aS as TickAuthSensor, aT as TickAuthSensorOptions, aU as TickAuthVerifier, b3 as TpsSensor, b4 as TpsSensorOptions, b5 as VarintHardeningSensor } from '../index-C5LdnkOB.js';
2
2
  import '../axis-sensor-BLUemDiZ.js';
3
3
  import 'zod';
4
4
  import '@nextera.one/axis-protocol';
@@ -2588,6 +2588,10 @@ var init_intent_router = __esm({
2588
2588
  this.handlerIntents = /* @__PURE__ */ new Map();
2589
2589
  /** Handler class name → intent namespace prefix (from @Handler('auth')) */
2590
2590
  this.handlerPrefixes = /* @__PURE__ */ new Map();
2591
+ /** Handler namespace prefix → handler class name, used by `handler...intent` lookup. */
2592
+ this.handlerByPrefix = /* @__PURE__ */ new Map();
2593
+ /** Intent → handler class name, avoids scanning handlerIntents for normal lookups. */
2594
+ this.handlerByIntent = /* @__PURE__ */ new Map();
2591
2595
  /** Handler class name → class-level sensor bindings (from @HandlerSensors) */
2592
2596
  this.handlerClassSensors = /* @__PURE__ */ new Map();
2593
2597
  /** Handler class name → class-level observer bindings (from @Handler({ observe: [...] })) */
@@ -2597,35 +2601,37 @@ var init_intent_router = __esm({
2597
2601
  this.sensorRegistry = sensorRegistry;
2598
2602
  }
2599
2603
  getSchema(intent) {
2600
- return this.intentSchemas.get(intent);
2604
+ return this.intentSchemas.get(this.resolveIntentAlias(intent));
2601
2605
  }
2602
2606
  getValidators(intent) {
2603
- return this.intentValidators.get(intent);
2607
+ return this.intentValidators.get(this.resolveIntentAlias(intent));
2604
2608
  }
2605
2609
  has(intent) {
2606
- return this.handlers.has(intent) || _IntentRouter.BUILTIN_INTENTS.has(intent);
2610
+ const resolved = this.resolveIntentAlias(intent);
2611
+ return this.handlers.has(resolved) || _IntentRouter.BUILTIN_INTENTS.has(resolved);
2607
2612
  }
2608
2613
  getRegisteredIntents() {
2609
2614
  return [..._IntentRouter.BUILTIN_INTENTS, ...this.handlers.keys()];
2610
2615
  }
2611
2616
  getIntentEntry(intent) {
2612
- if (!this.has(intent)) return null;
2617
+ const resolved = this.resolveIntentAlias(intent);
2618
+ if (!this.has(resolved)) return null;
2613
2619
  return {
2614
- schema: this.intentSchemas.get(intent),
2615
- validators: this.intentValidators.get(intent),
2616
- hasSensors: this.intentSensors.has(intent),
2617
- builtin: _IntentRouter.BUILTIN_INTENTS.has(intent),
2618
- kind: this.intentKinds.get(intent),
2619
- chain: this.intentChains.get(intent),
2620
- capsulePolicy: this.intentCapsulePolicies.get(intent),
2621
- observerCount: this.getObservers(intent).length
2620
+ schema: this.intentSchemas.get(resolved),
2621
+ validators: this.intentValidators.get(resolved),
2622
+ hasSensors: this.intentSensors.has(resolved),
2623
+ builtin: _IntentRouter.BUILTIN_INTENTS.has(resolved),
2624
+ kind: this.intentKinds.get(resolved),
2625
+ chain: this.intentChains.get(resolved),
2626
+ capsulePolicy: this.intentCapsulePolicies.get(resolved),
2627
+ observerCount: this.getObservers(resolved).length
2622
2628
  };
2623
2629
  }
2624
2630
  getChainConfig(intent) {
2625
- return this.intentChains.get(intent);
2631
+ return this.intentChains.get(this.resolveIntentAlias(intent));
2626
2632
  }
2627
2633
  getObservers(intent) {
2628
- return this.intentObservers.get(intent) || [];
2634
+ return this.intentObservers.get(this.resolveIntentAlias(intent)) || [];
2629
2635
  }
2630
2636
  /**
2631
2637
  * Registers a handler for a specific intent.
@@ -2668,6 +2674,14 @@ var init_intent_router = __esm({
2668
2674
  );
2669
2675
  const handlerSensors = Reflect.getMetadata(HANDLER_SENSORS_KEY, instance.constructor) || [];
2670
2676
  const handlerObservers = Reflect.getMetadata(OBSERVER_BINDINGS_KEY, instance.constructor) || [];
2677
+ if (prefix) {
2678
+ this.trackHandlerMeta(
2679
+ instance.constructor.name,
2680
+ prefix,
2681
+ handlerSensors,
2682
+ handlerObservers
2683
+ );
2684
+ }
2671
2685
  const proto = Object.getPrototypeOf(instance);
2672
2686
  for (const route of routes) {
2673
2687
  const intentName = route.absolute ? route.action : `${prefix}.${route.action}`;
@@ -2727,7 +2741,7 @@ var init_intent_router = __esm({
2727
2741
  try {
2728
2742
  const intentBytes = frame.headers.get(import_axis_protocol.TLV_INTENT);
2729
2743
  if (!intentBytes) throw new Error("Missing intent");
2730
- intent = this.decoder.decode(intentBytes);
2744
+ intent = this.resolveIntentAlias(this.decoder.decode(intentBytes));
2731
2745
  handlerRef = this.intentHandlerRefs.get(intent);
2732
2746
  const observerBindings = this.getObservers(intent);
2733
2747
  await this.emitIntentObservers(observerBindings, {
@@ -3037,25 +3051,25 @@ var init_intent_router = __esm({
3037
3051
  }
3038
3052
  // ─── Policy Getters ────────────────────────────────────────────────────────
3039
3053
  getSensitivity(intent) {
3040
- return this.intentSensitivity.get(intent);
3054
+ return this.intentSensitivity.get(this.resolveIntentAlias(intent));
3041
3055
  }
3042
3056
  getContract(intent) {
3043
- return this.intentContracts.get(intent);
3057
+ return this.intentContracts.get(this.resolveIntentAlias(intent));
3044
3058
  }
3045
3059
  getRequiredProof(intent) {
3046
- return this.intentRequiredProof.get(intent);
3060
+ return this.intentRequiredProof.get(this.resolveIntentAlias(intent));
3047
3061
  }
3048
3062
  isPublic(intent) {
3049
- return this.publicIntents.has(intent);
3063
+ return this.publicIntents.has(this.resolveIntentAlias(intent));
3050
3064
  }
3051
3065
  isAnonymous(intent) {
3052
- return this.anonymousIntents.has(intent);
3066
+ return this.anonymousIntents.has(this.resolveIntentAlias(intent));
3053
3067
  }
3054
3068
  isAuthorized(intent) {
3055
- return this.authorizedIntents.has(intent);
3069
+ return this.authorizedIntents.has(this.resolveIntentAlias(intent));
3056
3070
  }
3057
3071
  getRateLimit(intent) {
3058
- return this.intentRateLimits.get(intent);
3072
+ return this.intentRateLimits.get(this.resolveIntentAlias(intent));
3059
3073
  }
3060
3074
  // ─── Handler-level Getters ─────────────────────────────────────────────────
3061
3075
  /** All intents registered under the given handler class name. */
@@ -3064,10 +3078,8 @@ var init_intent_router = __esm({
3064
3078
  }
3065
3079
  /** Returns the handler class name that owns the given intent, or undefined if not found. */
3066
3080
  getHandlerByIntent(intent) {
3067
- for (const [handlerName, intents] of this.handlerIntents) {
3068
- if (intents.includes(intent)) return handlerName;
3069
- }
3070
- return void 0;
3081
+ const resolved = this.resolveIntentAlias(intent);
3082
+ return this.handlerByIntent.get(resolved);
3071
3083
  }
3072
3084
  /** All registered handler class names. */
3073
3085
  getRegisteredHandlers() {
@@ -3143,6 +3155,33 @@ var init_intent_router = __esm({
3143
3155
  getHandlerClassObservers(handlerName) {
3144
3156
  return this.handlerClassObservers.get(handlerName);
3145
3157
  }
3158
+ /**
3159
+ * Resolves the optional `handler...intent` wire shorthand to a registered
3160
+ * canonical intent. Existing exact intent names always win.
3161
+ */
3162
+ resolveIntentAlias(intent) {
3163
+ if (this.handlers.has(intent) || _IntentRouter.BUILTIN_INTENTS.has(intent)) {
3164
+ return intent;
3165
+ }
3166
+ const separator = "...";
3167
+ const separatorIndex = intent.indexOf(separator);
3168
+ if (separatorIndex <= 0) return intent;
3169
+ const handlerKey = intent.slice(0, separatorIndex);
3170
+ const action = intent.slice(separatorIndex + separator.length);
3171
+ if (!handlerKey || !action) return intent;
3172
+ const handlerName = this.handlerByPrefix.get(handlerKey) ?? (this.handlerIntents.has(handlerKey) ? handlerKey : void 0);
3173
+ if (!handlerName) return intent;
3174
+ const prefix = this.getHandlerPrefix(handlerName) ?? handlerKey;
3175
+ const handlerIntents = this.getHandlerIntents(handlerName);
3176
+ const prefixedIntent = `${prefix}.${action}`;
3177
+ if (handlerIntents.includes(prefixedIntent)) return prefixedIntent;
3178
+ if (handlerIntents.includes(action)) return action;
3179
+ const suffix = `.${action}`;
3180
+ const suffixMatches = handlerIntents.filter(
3181
+ (candidate) => candidate.endsWith(suffix)
3182
+ );
3183
+ return suffixMatches.length === 1 ? suffixMatches[0] : intent;
3184
+ }
3146
3185
  /** Full summary of a handler's registered intents and aggregated policies. Returns null if unknown. */
3147
3186
  getHandlerSummary(handlerName) {
3148
3187
  const intents = this.getHandlerIntents(handlerName);
@@ -3219,6 +3258,7 @@ var init_intent_router = __esm({
3219
3258
  }
3220
3259
  }
3221
3260
  trackHandlerIntent(handlerName, intent) {
3261
+ this.handlerByIntent.set(intent, handlerName);
3222
3262
  const existing = this.handlerIntents.get(handlerName);
3223
3263
  if (existing) {
3224
3264
  if (!existing.includes(intent)) existing.push(intent);
@@ -3232,6 +3272,7 @@ var init_intent_router = __esm({
3232
3272
  */
3233
3273
  trackHandlerMeta(className, prefix, sensors, observers) {
3234
3274
  this.handlerPrefixes.set(className, prefix);
3275
+ this.handlerByPrefix.set(prefix, className);
3235
3276
  if (sensors.length > 0) {
3236
3277
  this.handlerClassSensors.set(
3237
3278
  className,
@@ -11704,6 +11745,80 @@ var require_intent_registry_sensor = __commonJS({
11704
11745
  }
11705
11746
  });
11706
11747
 
11748
+ // src/sensors/law-article-presence.sensor.ts
11749
+ var require_law_article_presence_sensor = __commonJS({
11750
+ "src/sensors/law-article-presence.sensor.ts"(exports2) {
11751
+ "use strict";
11752
+ var __decorate = exports2 && exports2.__decorate || function(decorators, target, key, desc) {
11753
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
11754
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
11755
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
11756
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
11757
+ };
11758
+ var __metadata = exports2 && exports2.__metadata || function(k, v) {
11759
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
11760
+ };
11761
+ Object.defineProperty(exports2, "__esModule", { value: true });
11762
+ exports2.LawArticlePresenceSensor = void 0;
11763
+ var sensor_decorator_1 = (init_sensor_decorator(), __toCommonJS(sensor_decorator_exports));
11764
+ var sensor_bands_1 = (init_sensor_bands(), __toCommonJS(sensor_bands_exports));
11765
+ var LawArticlePresenceSensor = class LawArticlePresenceSensor {
11766
+ constructor(options) {
11767
+ this.options = options;
11768
+ this.name = "LawArticlePresenceSensor";
11769
+ this.order = sensor_bands_1.BAND.IDENTITY + 27;
11770
+ }
11771
+ supports(input) {
11772
+ if (this.mode() === "off")
11773
+ return false;
11774
+ if (!input.intent)
11775
+ return false;
11776
+ if (this.exemptIntents().includes(input.intent))
11777
+ return false;
11778
+ return true;
11779
+ }
11780
+ async run(input) {
11781
+ const intent = input.intent;
11782
+ const count = await this.options.getLawArticleCount(intent, input);
11783
+ if (count > 0) {
11784
+ return {
11785
+ action: "ALLOW",
11786
+ meta: { lawArticles: count }
11787
+ };
11788
+ }
11789
+ const reason = `Intent '${intent}' has no law article mapping`;
11790
+ if (this.mode() === "strict") {
11791
+ return {
11792
+ action: "DENY",
11793
+ code: this.options.missingCode ?? "CAPSULE_NOT_LAWFUL",
11794
+ reason
11795
+ };
11796
+ }
11797
+ return {
11798
+ action: "FLAG",
11799
+ scoreDelta: this.options.auditScoreDelta ?? 5,
11800
+ reasons: ["LAW_ARTICLE_MISSING", reason],
11801
+ meta: { lawArticles: 0 }
11802
+ };
11803
+ }
11804
+ mode() {
11805
+ const configured = this.options.mode;
11806
+ if (typeof configured === "function")
11807
+ return configured();
11808
+ return configured ?? "audit";
11809
+ }
11810
+ exemptIntents() {
11811
+ return this.options.exemptIntents ?? ["system.ping"];
11812
+ }
11813
+ };
11814
+ exports2.LawArticlePresenceSensor = LawArticlePresenceSensor;
11815
+ exports2.LawArticlePresenceSensor = LawArticlePresenceSensor = __decorate([
11816
+ (0, sensor_decorator_1.Sensor)({ phase: "POST_DECODE" }),
11817
+ __metadata("design:paramtypes", [Object])
11818
+ ], LawArticlePresenceSensor);
11819
+ }
11820
+ });
11821
+
11707
11822
  // src/sensors/law-evaluation.sensor.ts
11708
11823
  var require_law_evaluation_sensor = __commonJS({
11709
11824
  "src/sensors/law-evaluation.sensor.ts"(exports2) {
@@ -13176,6 +13291,7 @@ var init_sensors = __esm({
13176
13291
  __reExport(sensors_exports, __toESM(require_header_tlv_limit_sensor()), module.exports);
13177
13292
  __reExport(sensors_exports, __toESM(require_intent_allowlist_sensor()), module.exports);
13178
13293
  __reExport(sensors_exports, __toESM(require_intent_registry_sensor()), module.exports);
13294
+ __reExport(sensors_exports, __toESM(require_law_article_presence_sensor()), module.exports);
13179
13295
  __reExport(sensors_exports, __toESM(require_law_evaluation_sensor()), module.exports);
13180
13296
  __reExport(sensors_exports, __toESM(require_proof_presence_sensor()), module.exports);
13181
13297
  __reExport(sensors_exports, __toESM(require_protocol_strict_sensor()), module.exports);