@nextera.one/axis-server-sdk 1.9.0 → 2.1.0
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/README.md +52 -7
- package/dist/index.d.mts +337 -7
- package/dist/index.d.ts +337 -7
- package/dist/index.js +1718 -274
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1821 -373
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -39,6 +39,106 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
39
39
|
));
|
|
40
40
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
41
41
|
|
|
42
|
+
// src/decorators/chain.decorator.ts
|
|
43
|
+
var chain_decorator_exports = {};
|
|
44
|
+
__export(chain_decorator_exports, {
|
|
45
|
+
CHAIN_METADATA_KEY: () => CHAIN_METADATA_KEY,
|
|
46
|
+
Chain: () => Chain
|
|
47
|
+
});
|
|
48
|
+
import "reflect-metadata";
|
|
49
|
+
function Chain(options = {}) {
|
|
50
|
+
return (target, propertyKey) => {
|
|
51
|
+
const value = {
|
|
52
|
+
enabled: true,
|
|
53
|
+
...options
|
|
54
|
+
};
|
|
55
|
+
Reflect.defineMetadata(CHAIN_METADATA_KEY, value, target, propertyKey);
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
var CHAIN_METADATA_KEY;
|
|
59
|
+
var init_chain_decorator = __esm({
|
|
60
|
+
"src/decorators/chain.decorator.ts"() {
|
|
61
|
+
CHAIN_METADATA_KEY = "axis:chain";
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
// src/decorators/capsule-policy.decorator.ts
|
|
66
|
+
var capsule_policy_decorator_exports = {};
|
|
67
|
+
__export(capsule_policy_decorator_exports, {
|
|
68
|
+
CAPSULE_POLICY_METADATA_KEY: () => CAPSULE_POLICY_METADATA_KEY,
|
|
69
|
+
CapsulePolicy: () => CapsulePolicy,
|
|
70
|
+
mergeCapsulePolicyOptions: () => mergeCapsulePolicyOptions,
|
|
71
|
+
normalizeCapsulePolicyOptions: () => normalizeCapsulePolicyOptions
|
|
72
|
+
});
|
|
73
|
+
import "reflect-metadata";
|
|
74
|
+
function CapsulePolicy(options = {}) {
|
|
75
|
+
const normalized = normalizeCapsulePolicyOptions(options);
|
|
76
|
+
return ((target, propertyKey) => {
|
|
77
|
+
if (propertyKey !== void 0) {
|
|
78
|
+
Reflect.defineMetadata(
|
|
79
|
+
CAPSULE_POLICY_METADATA_KEY,
|
|
80
|
+
normalized,
|
|
81
|
+
target,
|
|
82
|
+
propertyKey
|
|
83
|
+
);
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
Reflect.defineMetadata(
|
|
87
|
+
CAPSULE_POLICY_METADATA_KEY,
|
|
88
|
+
normalized,
|
|
89
|
+
target
|
|
90
|
+
);
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
function normalizeCapsulePolicyOptions(options = {}) {
|
|
94
|
+
return {
|
|
95
|
+
required: options.required ?? true,
|
|
96
|
+
scopes: normalizeScopeValue(options.scopes),
|
|
97
|
+
scopeMode: options.scopeMode ?? "all",
|
|
98
|
+
intentBound: options.intentBound ?? true,
|
|
99
|
+
allowCapsuleRef: options.allowCapsuleRef ?? false
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
function mergeCapsulePolicyOptions(base, override) {
|
|
103
|
+
if (!base && !override) {
|
|
104
|
+
return void 0;
|
|
105
|
+
}
|
|
106
|
+
const normalizedBase = base ? normalizeCapsulePolicyOptions(base) : void 0;
|
|
107
|
+
const normalizedOverride = override ? normalizeCapsulePolicyOptions(override) : void 0;
|
|
108
|
+
const scopes = [
|
|
109
|
+
...toScopeList(normalizedBase?.scopes),
|
|
110
|
+
...toScopeList(normalizedOverride?.scopes)
|
|
111
|
+
];
|
|
112
|
+
return {
|
|
113
|
+
required: normalizedOverride?.required ?? normalizedBase?.required ?? true,
|
|
114
|
+
scopes: normalizeScopeValue(scopes),
|
|
115
|
+
scopeMode: normalizedOverride?.scopeMode ?? normalizedBase?.scopeMode ?? "all",
|
|
116
|
+
intentBound: normalizedOverride?.intentBound ?? normalizedBase?.intentBound ?? true,
|
|
117
|
+
allowCapsuleRef: normalizedOverride?.allowCapsuleRef ?? normalizedBase?.allowCapsuleRef ?? false
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
function normalizeScopeValue(value) {
|
|
121
|
+
const list = toScopeList(value);
|
|
122
|
+
if (list.length === 0) {
|
|
123
|
+
return void 0;
|
|
124
|
+
}
|
|
125
|
+
return list.length === 1 ? list[0] : list;
|
|
126
|
+
}
|
|
127
|
+
function toScopeList(value) {
|
|
128
|
+
if (!value) {
|
|
129
|
+
return [];
|
|
130
|
+
}
|
|
131
|
+
return Array.from(new Set(Array.isArray(value) ? value : [value])).filter(
|
|
132
|
+
(entry) => entry.trim().length > 0
|
|
133
|
+
);
|
|
134
|
+
}
|
|
135
|
+
var CAPSULE_POLICY_METADATA_KEY;
|
|
136
|
+
var init_capsule_policy_decorator = __esm({
|
|
137
|
+
"src/decorators/capsule-policy.decorator.ts"() {
|
|
138
|
+
CAPSULE_POLICY_METADATA_KEY = "axis:capsule:policy";
|
|
139
|
+
}
|
|
140
|
+
});
|
|
141
|
+
|
|
42
142
|
// src/decorators/handler.decorator.ts
|
|
43
143
|
var handler_decorator_exports = {};
|
|
44
144
|
__export(handler_decorator_exports, {
|
|
@@ -82,6 +182,7 @@ function Intent(action, options) {
|
|
|
82
182
|
absolute: options?.absolute,
|
|
83
183
|
frame: options?.frame,
|
|
84
184
|
kind: options?.kind,
|
|
185
|
+
chain: options?.chain,
|
|
85
186
|
bodyProfile: options?.bodyProfile,
|
|
86
187
|
tlv: options?.tlv,
|
|
87
188
|
dto: options?.dto
|
|
@@ -135,6 +236,73 @@ var init_intent_sensors_decorator = __esm({
|
|
|
135
236
|
}
|
|
136
237
|
});
|
|
137
238
|
|
|
239
|
+
// src/decorators/observer.decorator.ts
|
|
240
|
+
var observer_decorator_exports = {};
|
|
241
|
+
__export(observer_decorator_exports, {
|
|
242
|
+
OBSERVER_BINDINGS_KEY: () => OBSERVER_BINDINGS_KEY,
|
|
243
|
+
OBSERVER_METADATA_KEY: () => OBSERVER_METADATA_KEY,
|
|
244
|
+
Observer: () => Observer
|
|
245
|
+
});
|
|
246
|
+
import "reflect-metadata";
|
|
247
|
+
import { Injectable as Injectable2 } from "@nestjs/common";
|
|
248
|
+
function isBindingOptions(value) {
|
|
249
|
+
return !!value && typeof value === "object" && "use" in value;
|
|
250
|
+
}
|
|
251
|
+
function isDefinitionOptions(value) {
|
|
252
|
+
return !!value && typeof value === "object" && !Array.isArray(value) && !isBindingOptions(value);
|
|
253
|
+
}
|
|
254
|
+
function toBinding(input) {
|
|
255
|
+
if (!input) return null;
|
|
256
|
+
if (isBindingOptions(input)) {
|
|
257
|
+
const refs = Array.isArray(input.use) ? input.use : [input.use];
|
|
258
|
+
return { refs, tags: input.tags, events: input.events };
|
|
259
|
+
}
|
|
260
|
+
if (Array.isArray(input)) {
|
|
261
|
+
return { refs: input };
|
|
262
|
+
}
|
|
263
|
+
if (typeof input === "function" || typeof input === "string") {
|
|
264
|
+
return { refs: [input] };
|
|
265
|
+
}
|
|
266
|
+
return null;
|
|
267
|
+
}
|
|
268
|
+
function Observer(input) {
|
|
269
|
+
return ((target, propertyKey) => {
|
|
270
|
+
const binding = toBinding(input);
|
|
271
|
+
if (binding) {
|
|
272
|
+
if (propertyKey !== void 0) {
|
|
273
|
+
const existing2 = Reflect.getMetadata(OBSERVER_BINDINGS_KEY, target, propertyKey) || [];
|
|
274
|
+
existing2.push(binding);
|
|
275
|
+
Reflect.defineMetadata(
|
|
276
|
+
OBSERVER_BINDINGS_KEY,
|
|
277
|
+
existing2,
|
|
278
|
+
target,
|
|
279
|
+
propertyKey
|
|
280
|
+
);
|
|
281
|
+
return;
|
|
282
|
+
}
|
|
283
|
+
const existing = Reflect.getMetadata(OBSERVER_BINDINGS_KEY, target) || [];
|
|
284
|
+
existing.push(binding);
|
|
285
|
+
Reflect.defineMetadata(OBSERVER_BINDINGS_KEY, existing, target);
|
|
286
|
+
return;
|
|
287
|
+
}
|
|
288
|
+
if (propertyKey !== void 0) {
|
|
289
|
+
throw new Error(
|
|
290
|
+
"@Observer method usage must reference one or more observer classes or names"
|
|
291
|
+
);
|
|
292
|
+
}
|
|
293
|
+
const definition = isDefinitionOptions(input) ? input : {};
|
|
294
|
+
Reflect.defineMetadata(OBSERVER_METADATA_KEY, definition, target);
|
|
295
|
+
Injectable2()(target);
|
|
296
|
+
});
|
|
297
|
+
}
|
|
298
|
+
var OBSERVER_METADATA_KEY, OBSERVER_BINDINGS_KEY;
|
|
299
|
+
var init_observer_decorator = __esm({
|
|
300
|
+
"src/decorators/observer.decorator.ts"() {
|
|
301
|
+
OBSERVER_METADATA_KEY = "axis:observer";
|
|
302
|
+
OBSERVER_BINDINGS_KEY = "axis:observer:bindings";
|
|
303
|
+
}
|
|
304
|
+
});
|
|
305
|
+
|
|
138
306
|
// src/decorators/handler-sensors.decorator.ts
|
|
139
307
|
var handler_sensors_decorator_exports = {};
|
|
140
308
|
__export(handler_sensors_decorator_exports, {
|
|
@@ -473,113 +641,308 @@ var require_axis_response_dto = __commonJS({
|
|
|
473
641
|
}
|
|
474
642
|
});
|
|
475
643
|
|
|
476
|
-
// src/
|
|
477
|
-
var
|
|
478
|
-
__export(
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
644
|
+
// src/core/constants.ts
|
|
645
|
+
var constants_exports = {};
|
|
646
|
+
__export(constants_exports, {
|
|
647
|
+
AXIS_MAGIC: () => AXIS_MAGIC,
|
|
648
|
+
AXIS_VERSION: () => AXIS_VERSION,
|
|
649
|
+
BodyProfile: () => BodyProfile,
|
|
650
|
+
ERR_BAD_SIGNATURE: () => ERR_BAD_SIGNATURE,
|
|
651
|
+
ERR_CONTRACT_VIOLATION: () => ERR_CONTRACT_VIOLATION,
|
|
652
|
+
ERR_INVALID_PACKET: () => ERR_INVALID_PACKET,
|
|
653
|
+
ERR_REPLAY_DETECTED: () => ERR_REPLAY_DETECTED,
|
|
654
|
+
FLAG_BODY_TLV: () => FLAG_BODY_TLV,
|
|
655
|
+
FLAG_CHAIN_REQ: () => FLAG_CHAIN_REQ,
|
|
656
|
+
FLAG_HAS_WITNESS: () => FLAG_HAS_WITNESS,
|
|
657
|
+
MAX_BODY_LEN: () => MAX_BODY_LEN,
|
|
658
|
+
MAX_FRAME_LEN: () => MAX_FRAME_LEN,
|
|
659
|
+
MAX_HDR_LEN: () => MAX_HDR_LEN,
|
|
660
|
+
MAX_SIG_LEN: () => MAX_SIG_LEN,
|
|
661
|
+
NCERT_ALG: () => NCERT_ALG,
|
|
662
|
+
NCERT_EXP: () => NCERT_EXP,
|
|
663
|
+
NCERT_ISSUER_KID: () => NCERT_ISSUER_KID,
|
|
664
|
+
NCERT_KID: () => NCERT_KID,
|
|
665
|
+
NCERT_NBF: () => NCERT_NBF,
|
|
666
|
+
NCERT_NODE_ID: () => NCERT_NODE_ID,
|
|
667
|
+
NCERT_PAYLOAD: () => NCERT_PAYLOAD,
|
|
668
|
+
NCERT_PUB: () => NCERT_PUB,
|
|
669
|
+
NCERT_SCOPE: () => NCERT_SCOPE,
|
|
670
|
+
NCERT_SIG: () => NCERT_SIG,
|
|
671
|
+
PROOF_CAPSULE: () => PROOF_CAPSULE,
|
|
672
|
+
PROOF_JWT: () => PROOF_JWT,
|
|
673
|
+
PROOF_LOOM: () => PROOF_LOOM,
|
|
674
|
+
PROOF_MTLS: () => PROOF_MTLS,
|
|
675
|
+
PROOF_NONE: () => PROOF_NONE,
|
|
676
|
+
PROOF_WITNESS: () => PROOF_WITNESS,
|
|
677
|
+
ProofType: () => ProofType,
|
|
678
|
+
TLV_ACTOR_ID: () => TLV_ACTOR_ID,
|
|
679
|
+
TLV_AUD: () => TLV_AUD,
|
|
680
|
+
TLV_BODY_ARR: () => TLV_BODY_ARR,
|
|
681
|
+
TLV_BODY_OBJ: () => TLV_BODY_OBJ,
|
|
682
|
+
TLV_CAPSULE: () => TLV_CAPSULE,
|
|
683
|
+
TLV_EFFECT: () => TLV_EFFECT,
|
|
684
|
+
TLV_ERROR_CODE: () => TLV_ERROR_CODE,
|
|
685
|
+
TLV_ERROR_MSG: () => TLV_ERROR_MSG,
|
|
686
|
+
TLV_INDEX: () => TLV_INDEX,
|
|
687
|
+
TLV_INTENT: () => TLV_INTENT,
|
|
688
|
+
TLV_KID: () => TLV_KID,
|
|
689
|
+
TLV_LOOM_PRESENCE_ID: () => TLV_LOOM_PRESENCE_ID,
|
|
690
|
+
TLV_LOOM_THREAD_HASH: () => TLV_LOOM_THREAD_HASH,
|
|
691
|
+
TLV_LOOM_WRIT: () => TLV_LOOM_WRIT,
|
|
692
|
+
TLV_NODE: () => TLV_NODE,
|
|
693
|
+
TLV_NODE_CERT_HASH: () => TLV_NODE_CERT_HASH,
|
|
694
|
+
TLV_NODE_KID: () => TLV_NODE_KID,
|
|
695
|
+
TLV_NONCE: () => TLV_NONCE,
|
|
696
|
+
TLV_OFFSET: () => TLV_OFFSET,
|
|
697
|
+
TLV_OK: () => TLV_OK,
|
|
698
|
+
TLV_PID: () => TLV_PID,
|
|
699
|
+
TLV_PREV_HASH: () => TLV_PREV_HASH,
|
|
700
|
+
TLV_PROOF_REF: () => TLV_PROOF_REF,
|
|
701
|
+
TLV_PROOF_TYPE: () => TLV_PROOF_TYPE,
|
|
702
|
+
TLV_REALM: () => TLV_REALM,
|
|
703
|
+
TLV_RECEIPT_HASH: () => TLV_RECEIPT_HASH,
|
|
704
|
+
TLV_RID: () => TLV_RID,
|
|
705
|
+
TLV_SHA256_CHUNK: () => TLV_SHA256_CHUNK,
|
|
706
|
+
TLV_TRACE_ID: () => TLV_TRACE_ID,
|
|
707
|
+
TLV_TS: () => TLV_TS,
|
|
708
|
+
TLV_UPLOAD_ID: () => TLV_UPLOAD_ID
|
|
482
709
|
});
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
710
|
+
import {
|
|
711
|
+
AXIS_MAGIC,
|
|
712
|
+
AXIS_VERSION,
|
|
713
|
+
MAX_HDR_LEN,
|
|
714
|
+
MAX_BODY_LEN,
|
|
715
|
+
MAX_SIG_LEN,
|
|
716
|
+
MAX_FRAME_LEN,
|
|
717
|
+
FLAG_BODY_TLV,
|
|
718
|
+
FLAG_CHAIN_REQ,
|
|
719
|
+
FLAG_HAS_WITNESS,
|
|
720
|
+
TLV_PID,
|
|
721
|
+
TLV_TS,
|
|
722
|
+
TLV_INTENT,
|
|
723
|
+
TLV_ACTOR_ID,
|
|
724
|
+
TLV_PROOF_TYPE,
|
|
725
|
+
TLV_PROOF_REF,
|
|
726
|
+
TLV_NONCE,
|
|
727
|
+
TLV_AUD,
|
|
728
|
+
TLV_REALM,
|
|
729
|
+
TLV_NODE,
|
|
730
|
+
TLV_TRACE_ID,
|
|
731
|
+
TLV_KID,
|
|
732
|
+
TLV_RID,
|
|
733
|
+
TLV_OK,
|
|
734
|
+
TLV_EFFECT,
|
|
735
|
+
TLV_ERROR_CODE,
|
|
736
|
+
TLV_ERROR_MSG,
|
|
737
|
+
TLV_PREV_HASH,
|
|
738
|
+
TLV_RECEIPT_HASH,
|
|
739
|
+
TLV_NODE_KID,
|
|
740
|
+
TLV_NODE_CERT_HASH,
|
|
741
|
+
TLV_LOOM_PRESENCE_ID,
|
|
742
|
+
TLV_LOOM_WRIT,
|
|
743
|
+
TLV_LOOM_THREAD_HASH,
|
|
744
|
+
TLV_UPLOAD_ID,
|
|
745
|
+
TLV_INDEX,
|
|
746
|
+
TLV_OFFSET,
|
|
747
|
+
TLV_SHA256_CHUNK,
|
|
748
|
+
TLV_CAPSULE,
|
|
749
|
+
TLV_BODY_OBJ,
|
|
750
|
+
TLV_BODY_ARR,
|
|
751
|
+
NCERT_NODE_ID,
|
|
752
|
+
NCERT_KID,
|
|
753
|
+
NCERT_ALG,
|
|
754
|
+
NCERT_PUB,
|
|
755
|
+
NCERT_NBF,
|
|
756
|
+
NCERT_EXP,
|
|
757
|
+
NCERT_SCOPE,
|
|
758
|
+
NCERT_ISSUER_KID,
|
|
759
|
+
NCERT_PAYLOAD,
|
|
760
|
+
NCERT_SIG,
|
|
761
|
+
PROOF_NONE,
|
|
762
|
+
PROOF_CAPSULE,
|
|
763
|
+
PROOF_JWT,
|
|
764
|
+
PROOF_MTLS,
|
|
765
|
+
PROOF_LOOM,
|
|
766
|
+
PROOF_WITNESS,
|
|
767
|
+
ProofType,
|
|
768
|
+
BodyProfile,
|
|
769
|
+
ERR_INVALID_PACKET,
|
|
770
|
+
ERR_BAD_SIGNATURE,
|
|
771
|
+
ERR_REPLAY_DETECTED,
|
|
772
|
+
ERR_CONTRACT_VIOLATION
|
|
773
|
+
} from "@nextera.one/axis-protocol";
|
|
774
|
+
var init_constants = __esm({
|
|
775
|
+
"src/core/constants.ts"() {
|
|
776
|
+
}
|
|
777
|
+
});
|
|
778
|
+
|
|
779
|
+
// src/engine/axis-execution-context.ts
|
|
780
|
+
var axis_execution_context_exports = {};
|
|
781
|
+
__export(axis_execution_context_exports, {
|
|
782
|
+
AXIS_EXECUTION_CONTEXT_KEY: () => AXIS_EXECUTION_CONTEXT_KEY,
|
|
783
|
+
getAxisExecutionContext: () => getAxisExecutionContext,
|
|
784
|
+
mergeAxisExecutionContext: () => mergeAxisExecutionContext,
|
|
785
|
+
withAxisExecutionContext: () => withAxisExecutionContext
|
|
786
|
+
});
|
|
787
|
+
function getAxisExecutionContext(frame) {
|
|
788
|
+
return frame?.[AXIS_EXECUTION_CONTEXT_KEY];
|
|
789
|
+
}
|
|
790
|
+
function withAxisExecutionContext(target, context) {
|
|
791
|
+
Object.defineProperty(target, AXIS_EXECUTION_CONTEXT_KEY, {
|
|
792
|
+
value: context,
|
|
793
|
+
writable: true,
|
|
794
|
+
configurable: true,
|
|
795
|
+
enumerable: false
|
|
796
|
+
});
|
|
797
|
+
return target;
|
|
798
|
+
}
|
|
799
|
+
function mergeAxisExecutionContext(base, override) {
|
|
800
|
+
if (!base && !override) {
|
|
801
|
+
return void 0;
|
|
519
802
|
}
|
|
520
803
|
return {
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
retryAfterMs: sensorDecision.retryAfterMs
|
|
804
|
+
...base,
|
|
805
|
+
...override,
|
|
806
|
+
capsuleRef: {
|
|
807
|
+
...base?.capsuleRef || {},
|
|
808
|
+
...override?.capsuleRef || {}
|
|
809
|
+
}
|
|
528
810
|
};
|
|
529
811
|
}
|
|
530
|
-
var
|
|
531
|
-
var
|
|
532
|
-
"src/
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
retryAfterMs,
|
|
567
|
-
code: "RATE_LIMIT",
|
|
568
|
-
reasons: ["RATE_LIMIT"],
|
|
569
|
-
meta
|
|
570
|
-
};
|
|
571
|
-
},
|
|
572
|
-
flag(scoreDelta, reasons, meta) {
|
|
573
|
-
return {
|
|
574
|
-
decision: "FLAG" /* FLAG */,
|
|
575
|
-
allow: true,
|
|
576
|
-
riskScore: scoreDelta,
|
|
577
|
-
scoreDelta,
|
|
578
|
-
reasons,
|
|
579
|
-
meta
|
|
812
|
+
var AXIS_EXECUTION_CONTEXT_KEY;
|
|
813
|
+
var init_axis_execution_context = __esm({
|
|
814
|
+
"src/engine/axis-execution-context.ts"() {
|
|
815
|
+
AXIS_EXECUTION_CONTEXT_KEY = /* @__PURE__ */ Symbol.for("axis.executionContext");
|
|
816
|
+
}
|
|
817
|
+
});
|
|
818
|
+
|
|
819
|
+
// src/engine/registry/observer.registry.ts
|
|
820
|
+
var require_observer_registry = __commonJS({
|
|
821
|
+
"src/engine/registry/observer.registry.ts"(exports) {
|
|
822
|
+
"use strict";
|
|
823
|
+
var __decorate = exports && exports.__decorate || function(decorators, target, key, desc) {
|
|
824
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
825
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
826
|
+
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;
|
|
827
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
828
|
+
};
|
|
829
|
+
var ObserverRegistry_1;
|
|
830
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
831
|
+
exports.ObserverRegistry = void 0;
|
|
832
|
+
var common_1 = __require("@nestjs/common");
|
|
833
|
+
var ObserverRegistry2 = ObserverRegistry_1 = class ObserverRegistry {
|
|
834
|
+
constructor() {
|
|
835
|
+
this.logger = new common_1.Logger(ObserverRegistry_1.name);
|
|
836
|
+
this.byName = /* @__PURE__ */ new Map();
|
|
837
|
+
this.byType = /* @__PURE__ */ new Map();
|
|
838
|
+
}
|
|
839
|
+
register(instance, meta = {}) {
|
|
840
|
+
const name = meta.name || instance.name || instance.constructor.name;
|
|
841
|
+
const registration = {
|
|
842
|
+
name,
|
|
843
|
+
instance,
|
|
844
|
+
tags: meta.tags || [],
|
|
845
|
+
events: meta.events,
|
|
846
|
+
intents: meta.intents,
|
|
847
|
+
handlers: meta.handlers
|
|
580
848
|
};
|
|
849
|
+
this.byName.set(name, registration);
|
|
850
|
+
this.byType.set(instance.constructor, registration);
|
|
851
|
+
this.logger.debug(`Registered observer: ${name}`);
|
|
852
|
+
}
|
|
853
|
+
resolve(ref) {
|
|
854
|
+
if (typeof ref === "string") {
|
|
855
|
+
return this.byName.get(ref);
|
|
856
|
+
}
|
|
857
|
+
return this.byType.get(ref) || this.byName.get(ref.name);
|
|
858
|
+
}
|
|
859
|
+
list() {
|
|
860
|
+
return Array.from(this.byName.values()).sort((left, right) => left.name.localeCompare(right.name));
|
|
861
|
+
}
|
|
862
|
+
clear() {
|
|
863
|
+
this.byName.clear();
|
|
864
|
+
this.byType.clear();
|
|
865
|
+
}
|
|
866
|
+
};
|
|
867
|
+
exports.ObserverRegistry = ObserverRegistry2;
|
|
868
|
+
exports.ObserverRegistry = ObserverRegistry2 = ObserverRegistry_1 = __decorate([
|
|
869
|
+
(0, common_1.Injectable)()
|
|
870
|
+
], ObserverRegistry2);
|
|
871
|
+
}
|
|
872
|
+
});
|
|
873
|
+
|
|
874
|
+
// src/engine/observer-dispatcher.service.ts
|
|
875
|
+
var require_observer_dispatcher_service = __commonJS({
|
|
876
|
+
"src/engine/observer-dispatcher.service.ts"(exports) {
|
|
877
|
+
"use strict";
|
|
878
|
+
var __decorate = exports && exports.__decorate || function(decorators, target, key, desc) {
|
|
879
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
880
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
881
|
+
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;
|
|
882
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
883
|
+
};
|
|
884
|
+
var __metadata = exports && exports.__metadata || function(k, v) {
|
|
885
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
886
|
+
};
|
|
887
|
+
var ObserverDispatcherService_1;
|
|
888
|
+
var _a;
|
|
889
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
890
|
+
exports.ObserverDispatcherService = void 0;
|
|
891
|
+
var common_1 = __require("@nestjs/common");
|
|
892
|
+
var observer_registry_1 = require_observer_registry();
|
|
893
|
+
function unique(values) {
|
|
894
|
+
return Array.from(new Set(values));
|
|
895
|
+
}
|
|
896
|
+
var ObserverDispatcherService2 = ObserverDispatcherService_1 = class ObserverDispatcherService {
|
|
897
|
+
constructor(registry) {
|
|
898
|
+
this.registry = registry;
|
|
899
|
+
this.logger = new common_1.Logger(ObserverDispatcherService_1.name);
|
|
900
|
+
}
|
|
901
|
+
async dispatch(bindings, context) {
|
|
902
|
+
if (!bindings || bindings.length === 0)
|
|
903
|
+
return;
|
|
904
|
+
const invoked = /* @__PURE__ */ new Set();
|
|
905
|
+
for (const binding of bindings) {
|
|
906
|
+
if (binding.events && binding.events.length > 0 && !binding.events.includes(context.event)) {
|
|
907
|
+
continue;
|
|
908
|
+
}
|
|
909
|
+
for (const ref of binding.refs) {
|
|
910
|
+
const registration = this.registry.resolve(ref);
|
|
911
|
+
if (!registration) {
|
|
912
|
+
this.logger.warn(`Observer ${String(ref)} could not be resolved`);
|
|
913
|
+
continue;
|
|
914
|
+
}
|
|
915
|
+
if (invoked.has(registration.name))
|
|
916
|
+
continue;
|
|
917
|
+
if (registration.events && registration.events.length > 0 && !registration.events.includes(context.event)) {
|
|
918
|
+
continue;
|
|
919
|
+
}
|
|
920
|
+
const observerContext = {
|
|
921
|
+
...context,
|
|
922
|
+
observerTags: unique([
|
|
923
|
+
...registration.tags || [],
|
|
924
|
+
...binding.tags || [],
|
|
925
|
+
...context.observerTags || []
|
|
926
|
+
])
|
|
927
|
+
};
|
|
928
|
+
if (registration.instance.supports && !registration.instance.supports(observerContext)) {
|
|
929
|
+
continue;
|
|
930
|
+
}
|
|
931
|
+
try {
|
|
932
|
+
invoked.add(registration.name);
|
|
933
|
+
await registration.instance.observe(observerContext);
|
|
934
|
+
} catch (error) {
|
|
935
|
+
this.logger.warn(`Observer ${registration.name} failed during ${context.event}: ${error.message}`);
|
|
936
|
+
}
|
|
937
|
+
}
|
|
938
|
+
}
|
|
581
939
|
}
|
|
582
940
|
};
|
|
941
|
+
exports.ObserverDispatcherService = ObserverDispatcherService2;
|
|
942
|
+
exports.ObserverDispatcherService = ObserverDispatcherService2 = ObserverDispatcherService_1 = __decorate([
|
|
943
|
+
(0, common_1.Injectable)(),
|
|
944
|
+
__metadata("design:paramtypes", [typeof (_a = typeof observer_registry_1.ObserverRegistry !== "undefined" && observer_registry_1.ObserverRegistry) === "function" ? _a : Object])
|
|
945
|
+
], ObserverDispatcherService2);
|
|
583
946
|
}
|
|
584
947
|
});
|
|
585
948
|
|
|
@@ -1057,6 +1420,116 @@ var init_cce_witness_observer = __esm({
|
|
|
1057
1420
|
}
|
|
1058
1421
|
});
|
|
1059
1422
|
|
|
1423
|
+
// src/sensor/axis-sensor.ts
|
|
1424
|
+
var axis_sensor_exports = {};
|
|
1425
|
+
__export(axis_sensor_exports, {
|
|
1426
|
+
Decision: () => Decision,
|
|
1427
|
+
SensorDecisions: () => SensorDecisions,
|
|
1428
|
+
normalizeSensorDecision: () => normalizeSensorDecision
|
|
1429
|
+
});
|
|
1430
|
+
function normalizeSensorDecision(sensorDecision) {
|
|
1431
|
+
if ("action" in sensorDecision) {
|
|
1432
|
+
switch (sensorDecision.action) {
|
|
1433
|
+
case "ALLOW":
|
|
1434
|
+
return {
|
|
1435
|
+
allow: true,
|
|
1436
|
+
riskScore: 0,
|
|
1437
|
+
reasons: [],
|
|
1438
|
+
meta: sensorDecision.meta
|
|
1439
|
+
};
|
|
1440
|
+
case "DENY":
|
|
1441
|
+
return {
|
|
1442
|
+
allow: false,
|
|
1443
|
+
riskScore: 100,
|
|
1444
|
+
reasons: [sensorDecision.code, sensorDecision.reason].filter(
|
|
1445
|
+
Boolean
|
|
1446
|
+
),
|
|
1447
|
+
meta: sensorDecision.meta,
|
|
1448
|
+
retryAfterMs: sensorDecision.retryAfterMs
|
|
1449
|
+
};
|
|
1450
|
+
case "THROTTLE":
|
|
1451
|
+
return {
|
|
1452
|
+
allow: false,
|
|
1453
|
+
riskScore: 50,
|
|
1454
|
+
reasons: ["RATE_LIMIT"],
|
|
1455
|
+
retryAfterMs: sensorDecision.retryAfterMs,
|
|
1456
|
+
meta: sensorDecision.meta
|
|
1457
|
+
};
|
|
1458
|
+
case "FLAG":
|
|
1459
|
+
return {
|
|
1460
|
+
allow: true,
|
|
1461
|
+
riskScore: sensorDecision.scoreDelta,
|
|
1462
|
+
reasons: sensorDecision.reasons,
|
|
1463
|
+
meta: sensorDecision.meta
|
|
1464
|
+
};
|
|
1465
|
+
}
|
|
1466
|
+
}
|
|
1467
|
+
return {
|
|
1468
|
+
allow: sensorDecision.allow,
|
|
1469
|
+
riskScore: sensorDecision.riskScore,
|
|
1470
|
+
reasons: sensorDecision.reasons,
|
|
1471
|
+
tags: sensorDecision.tags,
|
|
1472
|
+
meta: sensorDecision.meta,
|
|
1473
|
+
tighten: sensorDecision.tighten,
|
|
1474
|
+
retryAfterMs: sensorDecision.retryAfterMs
|
|
1475
|
+
};
|
|
1476
|
+
}
|
|
1477
|
+
var Decision, SensorDecisions;
|
|
1478
|
+
var init_axis_sensor = __esm({
|
|
1479
|
+
"src/sensor/axis-sensor.ts"() {
|
|
1480
|
+
Decision = /* @__PURE__ */ ((Decision2) => {
|
|
1481
|
+
Decision2["ALLOW"] = "ALLOW";
|
|
1482
|
+
Decision2["DENY"] = "DENY";
|
|
1483
|
+
Decision2["THROTTLE"] = "THROTTLE";
|
|
1484
|
+
Decision2["FLAG"] = "FLAG";
|
|
1485
|
+
return Decision2;
|
|
1486
|
+
})(Decision || {});
|
|
1487
|
+
SensorDecisions = {
|
|
1488
|
+
allow(meta, tags) {
|
|
1489
|
+
return {
|
|
1490
|
+
decision: "ALLOW" /* ALLOW */,
|
|
1491
|
+
allow: true,
|
|
1492
|
+
riskScore: 0,
|
|
1493
|
+
reasons: [],
|
|
1494
|
+
tags,
|
|
1495
|
+
meta
|
|
1496
|
+
};
|
|
1497
|
+
},
|
|
1498
|
+
deny(code, reason, meta) {
|
|
1499
|
+
return {
|
|
1500
|
+
decision: "DENY" /* DENY */,
|
|
1501
|
+
allow: false,
|
|
1502
|
+
riskScore: 100,
|
|
1503
|
+
code,
|
|
1504
|
+
reasons: [code, reason].filter(Boolean),
|
|
1505
|
+
meta
|
|
1506
|
+
};
|
|
1507
|
+
},
|
|
1508
|
+
throttle(retryAfterMs, meta) {
|
|
1509
|
+
return {
|
|
1510
|
+
decision: "THROTTLE" /* THROTTLE */,
|
|
1511
|
+
allow: false,
|
|
1512
|
+
riskScore: 50,
|
|
1513
|
+
retryAfterMs,
|
|
1514
|
+
code: "RATE_LIMIT",
|
|
1515
|
+
reasons: ["RATE_LIMIT"],
|
|
1516
|
+
meta
|
|
1517
|
+
};
|
|
1518
|
+
},
|
|
1519
|
+
flag(scoreDelta, reasons, meta) {
|
|
1520
|
+
return {
|
|
1521
|
+
decision: "FLAG" /* FLAG */,
|
|
1522
|
+
allow: true,
|
|
1523
|
+
riskScore: scoreDelta,
|
|
1524
|
+
scoreDelta,
|
|
1525
|
+
reasons,
|
|
1526
|
+
meta
|
|
1527
|
+
};
|
|
1528
|
+
}
|
|
1529
|
+
};
|
|
1530
|
+
}
|
|
1531
|
+
});
|
|
1532
|
+
|
|
1060
1533
|
// src/cce/cce-pipeline.ts
|
|
1061
1534
|
var cce_pipeline_exports = {};
|
|
1062
1535
|
__export(cce_pipeline_exports, {
|
|
@@ -1289,50 +1762,330 @@ var init_cce_pipeline = __esm({
|
|
|
1289
1762
|
}
|
|
1290
1763
|
});
|
|
1291
1764
|
|
|
1292
|
-
// src/
|
|
1293
|
-
var
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1765
|
+
// src/core/axis-error.ts
|
|
1766
|
+
var axis_error_exports = {};
|
|
1767
|
+
__export(axis_error_exports, {
|
|
1768
|
+
AxisError: () => AxisError
|
|
1769
|
+
});
|
|
1770
|
+
var AxisError;
|
|
1771
|
+
var init_axis_error = __esm({
|
|
1772
|
+
"src/core/axis-error.ts"() {
|
|
1773
|
+
AxisError = class extends Error {
|
|
1774
|
+
constructor(code, message, httpStatus = 400, details) {
|
|
1775
|
+
super(message);
|
|
1776
|
+
this.code = code;
|
|
1777
|
+
this.httpStatus = httpStatus;
|
|
1778
|
+
this.details = details;
|
|
1779
|
+
this.name = "AxisError";
|
|
1780
|
+
}
|
|
1781
|
+
};
|
|
1782
|
+
}
|
|
1783
|
+
});
|
|
1784
|
+
|
|
1785
|
+
// src/security/scopes.ts
|
|
1786
|
+
function hasScope(scopes, required) {
|
|
1787
|
+
if (!Array.isArray(scopes) || scopes.length === 0) {
|
|
1788
|
+
return false;
|
|
1789
|
+
}
|
|
1790
|
+
if (scopes.includes(required)) {
|
|
1791
|
+
return true;
|
|
1792
|
+
}
|
|
1793
|
+
const [resource, id] = required.split(":");
|
|
1794
|
+
if (resource && id) {
|
|
1795
|
+
const wildcard = `${resource}:*`;
|
|
1796
|
+
if (scopes.includes(wildcard)) {
|
|
1797
|
+
return true;
|
|
1798
|
+
}
|
|
1799
|
+
}
|
|
1800
|
+
return false;
|
|
1801
|
+
}
|
|
1802
|
+
function parseScope(scope) {
|
|
1803
|
+
const parts = scope.split(":");
|
|
1804
|
+
if (parts.length !== 2) return null;
|
|
1805
|
+
return { resource: parts[0], id: parts[1] };
|
|
1806
|
+
}
|
|
1807
|
+
function canAccessResource(scopes, resourceType, resourceId) {
|
|
1808
|
+
const required = `${resourceType}:${resourceId}`;
|
|
1809
|
+
return hasScope(scopes, required);
|
|
1810
|
+
}
|
|
1811
|
+
var init_scopes = __esm({
|
|
1812
|
+
"src/security/scopes.ts"() {
|
|
1813
|
+
}
|
|
1814
|
+
});
|
|
1815
|
+
|
|
1816
|
+
// src/security/inline-capsule.ts
|
|
1817
|
+
var inline_capsule_exports = {};
|
|
1818
|
+
__export(inline_capsule_exports, {
|
|
1819
|
+
inlineCapsuleAllowsIntent: () => inlineCapsuleAllowsIntent,
|
|
1820
|
+
inlineCapsuleSatisfiesScopes: () => inlineCapsuleSatisfiesScopes,
|
|
1821
|
+
isInlineCapsuleExpired: () => isInlineCapsuleExpired,
|
|
1822
|
+
normalizeInlineCapsule: () => normalizeInlineCapsule,
|
|
1823
|
+
resolvePolicyScopes: () => resolvePolicyScopes
|
|
1824
|
+
});
|
|
1825
|
+
function normalizeInlineCapsule(input) {
|
|
1826
|
+
if (!input || typeof input !== "object" || Array.isArray(input)) {
|
|
1827
|
+
return null;
|
|
1828
|
+
}
|
|
1829
|
+
const raw = input;
|
|
1830
|
+
const scopes = normalizeStringList(raw.scopes ?? raw.scope);
|
|
1831
|
+
return {
|
|
1832
|
+
id: normalizeScalar(raw.id),
|
|
1833
|
+
actorId: normalizeScalar(raw.actorId),
|
|
1834
|
+
intents: normalizeStringList(raw.intents),
|
|
1835
|
+
issuedAt: normalizeTimestamp(raw.issuedAt ?? raw.iat),
|
|
1836
|
+
expiresAt: normalizeTimestamp(raw.expiresAt ?? raw.exp),
|
|
1837
|
+
realm: normalizeScalar(raw.realm),
|
|
1838
|
+
node: normalizeScalar(raw.node),
|
|
1839
|
+
scopes,
|
|
1840
|
+
raw
|
|
1841
|
+
};
|
|
1842
|
+
}
|
|
1843
|
+
function inlineCapsuleAllowsIntent(capsule, intent) {
|
|
1844
|
+
if (!capsule.intents || capsule.intents.length === 0) {
|
|
1845
|
+
return false;
|
|
1846
|
+
}
|
|
1847
|
+
for (const pattern of capsule.intents) {
|
|
1848
|
+
if (pattern === "*" || pattern === intent) {
|
|
1849
|
+
return true;
|
|
1850
|
+
}
|
|
1851
|
+
if (pattern.endsWith(".*")) {
|
|
1852
|
+
const prefix = pattern.slice(0, -1);
|
|
1853
|
+
if (intent.startsWith(prefix)) {
|
|
1854
|
+
return true;
|
|
1855
|
+
}
|
|
1856
|
+
}
|
|
1857
|
+
}
|
|
1858
|
+
return false;
|
|
1859
|
+
}
|
|
1860
|
+
function isInlineCapsuleExpired(capsule, clockSkewMs = 3e4) {
|
|
1861
|
+
if (capsule.expiresAt === void 0) {
|
|
1862
|
+
return false;
|
|
1863
|
+
}
|
|
1864
|
+
return BigInt(Date.now()) > capsule.expiresAt + BigInt(clockSkewMs);
|
|
1865
|
+
}
|
|
1866
|
+
function resolvePolicyScopes(scopes, context) {
|
|
1867
|
+
return scopes.map(
|
|
1868
|
+
(scope) => scope.replace(/\$\{([^}]+)\}/g, (_match, expression) => {
|
|
1869
|
+
const resolved = resolveTemplateExpression(expression.trim(), context);
|
|
1870
|
+
if (resolved === void 0 || resolved === null || resolved === "") {
|
|
1871
|
+
throw new Error(`CAPSULE_SCOPE_TEMPLATE_UNRESOLVED:${expression}`);
|
|
1872
|
+
}
|
|
1873
|
+
return String(resolved);
|
|
1874
|
+
})
|
|
1875
|
+
);
|
|
1876
|
+
}
|
|
1877
|
+
function inlineCapsuleSatisfiesScopes(capsule, requiredScopes, mode = "all") {
|
|
1878
|
+
if (!capsule.scopes || capsule.scopes.length === 0) {
|
|
1879
|
+
return false;
|
|
1880
|
+
}
|
|
1881
|
+
if (mode === "any") {
|
|
1882
|
+
return requiredScopes.some((scope) => hasScope(capsule.scopes, scope));
|
|
1883
|
+
}
|
|
1884
|
+
return requiredScopes.every((scope) => hasScope(capsule.scopes, scope));
|
|
1885
|
+
}
|
|
1886
|
+
function resolveTemplateExpression(expression, context) {
|
|
1887
|
+
if (expression === "intent") {
|
|
1888
|
+
return context.intent;
|
|
1889
|
+
}
|
|
1890
|
+
if (expression === "actorId") {
|
|
1891
|
+
return context.actorId;
|
|
1892
|
+
}
|
|
1893
|
+
if (expression === "chainId") {
|
|
1894
|
+
return context.chainId;
|
|
1895
|
+
}
|
|
1896
|
+
if (expression === "stepId") {
|
|
1897
|
+
return context.stepId;
|
|
1898
|
+
}
|
|
1899
|
+
if (expression.startsWith("body.")) {
|
|
1900
|
+
return getNestedValue(context.body, expression.slice(5));
|
|
1901
|
+
}
|
|
1902
|
+
return void 0;
|
|
1903
|
+
}
|
|
1904
|
+
function getNestedValue(value, path2) {
|
|
1905
|
+
if (!value || typeof value !== "object") {
|
|
1906
|
+
return void 0;
|
|
1907
|
+
}
|
|
1908
|
+
return path2.split(".").reduce((current, segment) => {
|
|
1909
|
+
if (!current || typeof current !== "object") {
|
|
1910
|
+
return void 0;
|
|
1911
|
+
}
|
|
1912
|
+
return current[segment];
|
|
1913
|
+
}, value);
|
|
1914
|
+
}
|
|
1915
|
+
function normalizeScalar(value) {
|
|
1916
|
+
if (typeof value === "string") {
|
|
1917
|
+
return value;
|
|
1918
|
+
}
|
|
1919
|
+
if (value instanceof Uint8Array) {
|
|
1920
|
+
return Buffer.from(value).toString("hex");
|
|
1921
|
+
}
|
|
1922
|
+
return void 0;
|
|
1923
|
+
}
|
|
1924
|
+
function normalizeStringList(value) {
|
|
1925
|
+
if (!value) {
|
|
1926
|
+
return void 0;
|
|
1927
|
+
}
|
|
1928
|
+
const list = Array.isArray(value) ? value : [value];
|
|
1929
|
+
const normalized = list.map((entry) => typeof entry === "string" ? entry : void 0).filter((entry) => !!entry && entry.trim().length > 0);
|
|
1930
|
+
return normalized.length > 0 ? Array.from(new Set(normalized)) : void 0;
|
|
1931
|
+
}
|
|
1932
|
+
function normalizeTimestamp(value) {
|
|
1933
|
+
if (typeof value === "bigint") {
|
|
1934
|
+
return value;
|
|
1935
|
+
}
|
|
1936
|
+
if (typeof value === "number" && Number.isFinite(value)) {
|
|
1937
|
+
return BigInt(Math.trunc(value));
|
|
1938
|
+
}
|
|
1939
|
+
if (typeof value === "string" && value.trim().length > 0) {
|
|
1940
|
+
try {
|
|
1941
|
+
return BigInt(value);
|
|
1942
|
+
} catch {
|
|
1943
|
+
return void 0;
|
|
1944
|
+
}
|
|
1945
|
+
}
|
|
1946
|
+
return void 0;
|
|
1947
|
+
}
|
|
1948
|
+
var init_inline_capsule = __esm({
|
|
1949
|
+
"src/security/inline-capsule.ts"() {
|
|
1950
|
+
init_scopes();
|
|
1951
|
+
}
|
|
1952
|
+
});
|
|
1953
|
+
|
|
1954
|
+
// src/engine/intent.router.ts
|
|
1955
|
+
var require_intent_router = __commonJS({
|
|
1956
|
+
"src/engine/intent.router.ts"(exports) {
|
|
1957
|
+
"use strict";
|
|
1958
|
+
var __createBinding = exports && exports.__createBinding || (Object.create ? (function(o, m, k, k2) {
|
|
1959
|
+
if (k2 === void 0) k2 = k;
|
|
1960
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
1961
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
1962
|
+
desc = { enumerable: true, get: function() {
|
|
1963
|
+
return m[k];
|
|
1964
|
+
} };
|
|
1965
|
+
}
|
|
1966
|
+
Object.defineProperty(o, k2, desc);
|
|
1967
|
+
}) : (function(o, m, k, k2) {
|
|
1968
|
+
if (k2 === void 0) k2 = k;
|
|
1969
|
+
o[k2] = m[k];
|
|
1970
|
+
}));
|
|
1971
|
+
var __setModuleDefault = exports && exports.__setModuleDefault || (Object.create ? (function(o, v) {
|
|
1972
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
1973
|
+
}) : function(o, v) {
|
|
1974
|
+
o["default"] = v;
|
|
1975
|
+
});
|
|
1976
|
+
var __decorate = exports && exports.__decorate || function(decorators, target, key, desc) {
|
|
1977
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1978
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
1979
|
+
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;
|
|
1980
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1981
|
+
};
|
|
1982
|
+
var __importStar = exports && exports.__importStar || /* @__PURE__ */ (function() {
|
|
1983
|
+
var ownKeys = function(o) {
|
|
1984
|
+
ownKeys = Object.getOwnPropertyNames || function(o2) {
|
|
1985
|
+
var ar = [];
|
|
1986
|
+
for (var k in o2) if (Object.prototype.hasOwnProperty.call(o2, k)) ar[ar.length] = k;
|
|
1987
|
+
return ar;
|
|
1988
|
+
};
|
|
1989
|
+
return ownKeys(o);
|
|
1990
|
+
};
|
|
1991
|
+
return function(mod) {
|
|
1992
|
+
if (mod && mod.__esModule) return mod;
|
|
1993
|
+
var result = {};
|
|
1994
|
+
if (mod != null) {
|
|
1995
|
+
for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
1996
|
+
}
|
|
1997
|
+
__setModuleDefault(result, mod);
|
|
1998
|
+
return result;
|
|
1999
|
+
};
|
|
2000
|
+
})();
|
|
2001
|
+
var __metadata = exports && exports.__metadata || function(k, v) {
|
|
2002
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
2003
|
+
};
|
|
2004
|
+
var __param = exports && exports.__param || function(paramIndex, decorator) {
|
|
2005
|
+
return function(target, key) {
|
|
2006
|
+
decorator(target, key, paramIndex);
|
|
2007
|
+
};
|
|
2008
|
+
};
|
|
2009
|
+
var IntentRouter_1;
|
|
2010
|
+
var _a;
|
|
2011
|
+
var _b;
|
|
2012
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2013
|
+
exports.IntentRouter = void 0;
|
|
2014
|
+
var common_1 = __require("@nestjs/common");
|
|
2015
|
+
var core_1 = __require("@nestjs/core");
|
|
2016
|
+
var axis_protocol_1 = __require("@nextera.one/axis-protocol");
|
|
2017
|
+
var cce_pipeline_1 = (init_cce_pipeline(), __toCommonJS(cce_pipeline_exports));
|
|
2018
|
+
var axis_error_1 = (init_axis_error(), __toCommonJS(axis_error_exports));
|
|
2019
|
+
var constants_1 = (init_constants(), __toCommonJS(constants_exports));
|
|
2020
|
+
var capsule_policy_decorator_1 = (init_capsule_policy_decorator(), __toCommonJS(capsule_policy_decorator_exports));
|
|
2021
|
+
var chain_decorator_1 = (init_chain_decorator(), __toCommonJS(chain_decorator_exports));
|
|
2022
|
+
var dto_schema_util_1 = require_dto_schema_util();
|
|
2023
|
+
var handler_sensors_decorator_1 = (init_handler_sensors_decorator(), __toCommonJS(handler_sensors_decorator_exports));
|
|
2024
|
+
var handler_decorator_1 = (init_handler_decorator(), __toCommonJS(handler_decorator_exports));
|
|
2025
|
+
var intent_body_decorator_1 = (init_intent_body_decorator(), __toCommonJS(intent_body_decorator_exports));
|
|
2026
|
+
var intent_sensors_decorator_1 = (init_intent_sensors_decorator(), __toCommonJS(intent_sensors_decorator_exports));
|
|
2027
|
+
var intent_decorator_1 = (init_intent_decorator(), __toCommonJS(intent_decorator_exports));
|
|
2028
|
+
var observer_decorator_1 = (init_observer_decorator(), __toCommonJS(observer_decorator_exports));
|
|
2029
|
+
var inline_capsule_1 = (init_inline_capsule(), __toCommonJS(inline_capsule_exports));
|
|
2030
|
+
var axis_sensor_1 = (init_axis_sensor(), __toCommonJS(axis_sensor_exports));
|
|
2031
|
+
var axis_execution_context_1 = (init_axis_execution_context(), __toCommonJS(axis_execution_context_exports));
|
|
2032
|
+
var observer_dispatcher_service_1 = require_observer_dispatcher_service();
|
|
2033
|
+
function observerRefKey(ref) {
|
|
2034
|
+
return typeof ref === "string" ? ref : ref.name;
|
|
2035
|
+
}
|
|
2036
|
+
function mergeObserverBindings(bindings) {
|
|
2037
|
+
const merged = /* @__PURE__ */ new Map();
|
|
2038
|
+
for (const binding of bindings) {
|
|
2039
|
+
for (const ref of binding.refs) {
|
|
2040
|
+
const key = observerRefKey(ref);
|
|
2041
|
+
const existing = merged.get(key);
|
|
2042
|
+
if (!existing) {
|
|
2043
|
+
merged.set(key, {
|
|
2044
|
+
refs: [ref],
|
|
2045
|
+
tags: binding.tags ? [...new Set(binding.tags)] : void 0,
|
|
2046
|
+
events: binding.events ? [...new Set(binding.events)] : void 0
|
|
2047
|
+
});
|
|
2048
|
+
continue;
|
|
2049
|
+
}
|
|
2050
|
+
existing.tags = Array.from(/* @__PURE__ */ new Set([...existing.tags || [], ...binding.tags || []]));
|
|
2051
|
+
existing.events = existing.events === void 0 || binding.events === void 0 ? void 0 : Array.from(/* @__PURE__ */ new Set([...existing.events, ...binding.events]));
|
|
2052
|
+
}
|
|
2053
|
+
}
|
|
2054
|
+
return Array.from(merged.values());
|
|
2055
|
+
}
|
|
2056
|
+
function normalizeChainConfig(decoratorConfig, intentConfig) {
|
|
2057
|
+
if (decoratorConfig) {
|
|
2058
|
+
return decoratorConfig;
|
|
2059
|
+
}
|
|
2060
|
+
if (!intentConfig) {
|
|
2061
|
+
return void 0;
|
|
2062
|
+
}
|
|
2063
|
+
if (intentConfig === true) {
|
|
2064
|
+
return { enabled: true };
|
|
2065
|
+
}
|
|
2066
|
+
return {
|
|
2067
|
+
enabled: true,
|
|
2068
|
+
...intentConfig
|
|
2069
|
+
};
|
|
2070
|
+
}
|
|
2071
|
+
var IntentRouter2 = IntentRouter_1 = class IntentRouter {
|
|
2072
|
+
constructor(moduleRef, observerDispatcher) {
|
|
2073
|
+
this.moduleRef = moduleRef;
|
|
2074
|
+
this.observerDispatcher = observerDispatcher;
|
|
2075
|
+
this.logger = new common_1.Logger(IntentRouter_1.name);
|
|
2076
|
+
this.decoder = new TextDecoder();
|
|
2077
|
+
this.encoder = new TextEncoder();
|
|
2078
|
+
this.handlers = /* @__PURE__ */ new Map();
|
|
2079
|
+
this.intentSensors = /* @__PURE__ */ new Map();
|
|
2080
|
+
this.intentDecoders = /* @__PURE__ */ new Map();
|
|
2081
|
+
this.intentSchemas = /* @__PURE__ */ new Map();
|
|
2082
|
+
this.intentValidators = /* @__PURE__ */ new Map();
|
|
2083
|
+
this.intentKinds = /* @__PURE__ */ new Map();
|
|
2084
|
+
this.intentChains = /* @__PURE__ */ new Map();
|
|
2085
|
+
this.intentObservers = /* @__PURE__ */ new Map();
|
|
2086
|
+
this.intentCapsulePolicies = /* @__PURE__ */ new Map();
|
|
2087
|
+
this.cceHandlers = /* @__PURE__ */ new Map();
|
|
2088
|
+
this.ccePipelineConfig = null;
|
|
1336
2089
|
}
|
|
1337
2090
|
getSchema(intent) {
|
|
1338
2091
|
return this.intentSchemas.get(intent);
|
|
@@ -1354,9 +2107,18 @@ var require_intent_router = __commonJS({
|
|
|
1354
2107
|
validators: this.intentValidators.get(intent),
|
|
1355
2108
|
hasSensors: this.intentSensors.has(intent),
|
|
1356
2109
|
builtin: IntentRouter_1.BUILTIN_INTENTS.has(intent),
|
|
1357
|
-
kind: this.intentKinds.get(intent)
|
|
2110
|
+
kind: this.intentKinds.get(intent),
|
|
2111
|
+
chain: this.intentChains.get(intent),
|
|
2112
|
+
capsulePolicy: this.intentCapsulePolicies.get(intent),
|
|
2113
|
+
observerCount: this.getObservers(intent).length
|
|
1358
2114
|
};
|
|
1359
2115
|
}
|
|
2116
|
+
getChainConfig(intent) {
|
|
2117
|
+
return this.intentChains.get(intent);
|
|
2118
|
+
}
|
|
2119
|
+
getObservers(intent) {
|
|
2120
|
+
return this.intentObservers.get(intent) || [];
|
|
2121
|
+
}
|
|
1360
2122
|
register(intent, handler) {
|
|
1361
2123
|
this.handlers.set(intent, handler);
|
|
1362
2124
|
}
|
|
@@ -1364,7 +2126,10 @@ var require_intent_router = __commonJS({
|
|
|
1364
2126
|
const handlerMeta = Reflect.getMetadata(handler_decorator_1.HANDLER_METADATA_KEY, instance.constructor);
|
|
1365
2127
|
const prefix = handlerMeta?.intent || instance.name;
|
|
1366
2128
|
const routes = Reflect.getMetadata(intent_decorator_1.INTENT_ROUTES_KEY, instance.constructor) || [];
|
|
2129
|
+
const routedMethods = new Set(routes.map((route) => String(route.methodName)));
|
|
1367
2130
|
const handlerSensors = Reflect.getMetadata(handler_sensors_decorator_1.HANDLER_SENSORS_KEY, instance.constructor) || [];
|
|
2131
|
+
const handlerObservers = Reflect.getMetadata(observer_decorator_1.OBSERVER_BINDINGS_KEY, instance.constructor) || [];
|
|
2132
|
+
const proto = Object.getPrototypeOf(instance);
|
|
1368
2133
|
for (const route of routes) {
|
|
1369
2134
|
const intentName = route.absolute ? route.action : `${prefix}.${route.action}`;
|
|
1370
2135
|
const fn = instance[route.methodName].bind(instance);
|
|
@@ -1373,27 +2138,36 @@ var require_intent_router = __commonJS({
|
|
|
1373
2138
|
} else {
|
|
1374
2139
|
this.register(intentName, fn);
|
|
1375
2140
|
}
|
|
1376
|
-
this.registerIntentMeta(intentName,
|
|
2141
|
+
this.registerIntentMeta(intentName, proto, String(route.methodName), handlerSensors, handlerObservers);
|
|
1377
2142
|
}
|
|
1378
|
-
const proto = Object.getPrototypeOf(instance);
|
|
1379
2143
|
for (const key of Object.getOwnPropertyNames(proto)) {
|
|
2144
|
+
if (routedMethods.has(key))
|
|
2145
|
+
continue;
|
|
1380
2146
|
const meta = Reflect.getMetadata(intent_decorator_1.INTENT_METADATA_KEY, proto, key);
|
|
1381
2147
|
if (!meta?.intent)
|
|
1382
2148
|
continue;
|
|
1383
|
-
|
|
1384
|
-
|
|
2149
|
+
const intentName = meta.absolute ? meta.intent : `${prefix}.${meta.intent}`;
|
|
2150
|
+
if (!this.handlers.has(intentName)) {
|
|
2151
|
+
this.register(intentName, instance[key].bind(instance));
|
|
1385
2152
|
}
|
|
1386
|
-
this.registerIntentMeta(
|
|
2153
|
+
this.registerIntentMeta(intentName, proto, key, handlerSensors, handlerObservers);
|
|
1387
2154
|
}
|
|
1388
2155
|
}
|
|
1389
2156
|
async route(frame) {
|
|
1390
2157
|
const start = process.hrtime();
|
|
1391
2158
|
let intent = "unknown";
|
|
1392
2159
|
try {
|
|
1393
|
-
const intentBytes = frame.headers.get(
|
|
2160
|
+
const intentBytes = frame.headers.get(constants_1.TLV_INTENT);
|
|
1394
2161
|
if (!intentBytes)
|
|
1395
2162
|
throw new Error("Missing intent");
|
|
1396
|
-
intent =
|
|
2163
|
+
intent = this.decoder.decode(intentBytes);
|
|
2164
|
+
const observerBindings = this.getObservers(intent);
|
|
2165
|
+
await this.emitIntentObservers(observerBindings, {
|
|
2166
|
+
event: "intent.received",
|
|
2167
|
+
timestamp: Date.now(),
|
|
2168
|
+
intent,
|
|
2169
|
+
frame
|
|
2170
|
+
});
|
|
1397
2171
|
let effect;
|
|
1398
2172
|
if (intent === "system.ping" || intent === "public.ping") {
|
|
1399
2173
|
this.logger.debug("PING received");
|
|
@@ -1425,25 +2199,35 @@ var require_intent_router = __commonJS({
|
|
|
1425
2199
|
effect: "echo",
|
|
1426
2200
|
body: frame.body
|
|
1427
2201
|
};
|
|
2202
|
+
} else if (intent === "CHAIN.EXEC" || intent === "axis.chain.exec") {
|
|
2203
|
+
const chainRequest = this.parseChainRequestBody(frame.body);
|
|
2204
|
+
effect = await this.executeChainRequest(frame, chainRequest);
|
|
1428
2205
|
} else if (intent === "INTENT.EXEC" || intent === "axis.intent.exec") {
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
return await this.route(innerFrame);
|
|
1444
|
-
} catch (e) {
|
|
1445
|
-
throw new Error(`INTENT.EXEC unwrapping failed: ${e.message}`);
|
|
2206
|
+
const execBody = this.parseIntentExecBody(frame.body);
|
|
2207
|
+
const innerIntent = execBody.intent;
|
|
2208
|
+
const innerArgs = execBody.args || {};
|
|
2209
|
+
if (!innerIntent) {
|
|
2210
|
+
throw new Error("INTENT.EXEC missing inner intent");
|
|
2211
|
+
}
|
|
2212
|
+
this.logger.debug(`EXEC: routing to inner intent '${innerIntent}'`);
|
|
2213
|
+
const innerHeaders = new Map(frame.headers);
|
|
2214
|
+
innerHeaders.set(constants_1.TLV_INTENT, this.encoder.encode(innerIntent));
|
|
2215
|
+
const inlineCapsule = this.toInlineCapsuleRecord(execBody.capsule);
|
|
2216
|
+
const capsuleId = this.extractInlineCapsuleId(inlineCapsule);
|
|
2217
|
+
if (capsuleId) {
|
|
2218
|
+
innerHeaders.set(constants_1.TLV_CAPSULE, this.encoder.encode(capsuleId));
|
|
2219
|
+
innerHeaders.set(constants_1.TLV_PROOF_REF, this.encoder.encode(capsuleId));
|
|
1446
2220
|
}
|
|
2221
|
+
const innerFrame = (0, axis_execution_context_1.withAxisExecutionContext)({
|
|
2222
|
+
...frame,
|
|
2223
|
+
headers: innerHeaders,
|
|
2224
|
+
body: this.encodeJson(innerArgs)
|
|
2225
|
+
}, (0, axis_execution_context_1.mergeAxisExecutionContext)((0, axis_execution_context_1.getAxisExecutionContext)(frame), {
|
|
2226
|
+
metaIntent: "INTENT.EXEC",
|
|
2227
|
+
actorId: this.getActorIdFromFrame(frame),
|
|
2228
|
+
inlineCapsule
|
|
2229
|
+
}) || {});
|
|
2230
|
+
effect = await this.route(innerFrame);
|
|
1447
2231
|
} else {
|
|
1448
2232
|
const handler = this.handlers.get(intent);
|
|
1449
2233
|
if (!handler) {
|
|
@@ -1462,6 +2246,7 @@ var require_intent_router = __commonJS({
|
|
|
1462
2246
|
throw new Error(`IntentBody decode failed for ${intent}: ${decodeErr.message}`);
|
|
1463
2247
|
}
|
|
1464
2248
|
}
|
|
2249
|
+
this.enforceCapsulePolicy(intent, frame, decodedBody, this.getEffectiveCapsulePolicy(intent, frame));
|
|
1465
2250
|
if (typeof handler === "function") {
|
|
1466
2251
|
const resultBody = decoder ? await handler(decodedBody, frame.headers) : await handler(frame.body, frame.headers);
|
|
1467
2252
|
effect = {
|
|
@@ -1484,9 +2269,24 @@ var require_intent_router = __commonJS({
|
|
|
1484
2269
|
}
|
|
1485
2270
|
}
|
|
1486
2271
|
}
|
|
2272
|
+
await this.emitIntentObservers(observerBindings, {
|
|
2273
|
+
event: "intent.completed",
|
|
2274
|
+
timestamp: Date.now(),
|
|
2275
|
+
intent,
|
|
2276
|
+
frame,
|
|
2277
|
+
effect,
|
|
2278
|
+
metadata: effect.metadata
|
|
2279
|
+
});
|
|
1487
2280
|
this.logIntent(intent, start, true);
|
|
1488
2281
|
return effect;
|
|
1489
2282
|
} catch (e) {
|
|
2283
|
+
await this.emitIntentObservers(this.getObservers(intent), {
|
|
2284
|
+
event: "intent.failed",
|
|
2285
|
+
timestamp: Date.now(),
|
|
2286
|
+
intent,
|
|
2287
|
+
frame,
|
|
2288
|
+
error: e.message
|
|
2289
|
+
});
|
|
1490
2290
|
this.logIntent(intent, start, false, e.message);
|
|
1491
2291
|
throw e;
|
|
1492
2292
|
}
|
|
@@ -1500,7 +2300,7 @@ var require_intent_router = __commonJS({
|
|
|
1500
2300
|
this.logger.warn(`${intent} failed in ${ms}ms - ${error}`);
|
|
1501
2301
|
}
|
|
1502
2302
|
}
|
|
1503
|
-
registerIntentMeta(intent, proto, methodName, handlerSensors) {
|
|
2303
|
+
registerIntentMeta(intent, proto, methodName, handlerSensors, handlerObservers) {
|
|
1504
2304
|
const decoder = Reflect.getMetadata(intent_body_decorator_1.INTENT_BODY_KEY, proto, methodName);
|
|
1505
2305
|
if (decoder) {
|
|
1506
2306
|
this.intentDecoders.set(intent, decoder);
|
|
@@ -1513,14 +2313,38 @@ var require_intent_router = __commonJS({
|
|
|
1513
2313
|
if (combined.length > 0) {
|
|
1514
2314
|
this.intentSensors.set(intent, combined);
|
|
1515
2315
|
}
|
|
2316
|
+
const methodObservers = Reflect.getMetadata(observer_decorator_1.OBSERVER_BINDINGS_KEY, proto, methodName) || [];
|
|
2317
|
+
const observers = mergeObserverBindings([
|
|
2318
|
+
...handlerObservers || [],
|
|
2319
|
+
...methodObservers
|
|
2320
|
+
]);
|
|
2321
|
+
if (observers.length > 0) {
|
|
2322
|
+
this.intentObservers.set(intent, observers);
|
|
2323
|
+
}
|
|
2324
|
+
const handlerCapsulePolicy = Reflect.getMetadata(capsule_policy_decorator_1.CAPSULE_POLICY_METADATA_KEY, proto.constructor);
|
|
2325
|
+
const methodCapsulePolicy = Reflect.getMetadata(capsule_policy_decorator_1.CAPSULE_POLICY_METADATA_KEY, proto, methodName);
|
|
2326
|
+
const capsulePolicy = (0, capsule_policy_decorator_1.mergeCapsulePolicyOptions)(handlerCapsulePolicy, methodCapsulePolicy);
|
|
2327
|
+
if (capsulePolicy) {
|
|
2328
|
+
this.intentCapsulePolicies.set(intent, capsulePolicy);
|
|
2329
|
+
}
|
|
1516
2330
|
const meta = Reflect.getMetadata(intent_decorator_1.INTENT_METADATA_KEY, proto, methodName);
|
|
1517
2331
|
if (meta) {
|
|
1518
|
-
this.storeSchema(meta);
|
|
2332
|
+
this.storeSchema({ ...meta, intent });
|
|
1519
2333
|
if (meta.kind) {
|
|
1520
2334
|
this.intentKinds.set(intent, meta.kind);
|
|
1521
2335
|
}
|
|
2336
|
+
const chainMeta = Reflect.getMetadata(chain_decorator_1.CHAIN_METADATA_KEY, proto, methodName);
|
|
2337
|
+
const chainConfig = normalizeChainConfig(chainMeta, meta.chain);
|
|
2338
|
+
if (chainConfig) {
|
|
2339
|
+
this.intentChains.set(intent, chainConfig);
|
|
2340
|
+
}
|
|
1522
2341
|
}
|
|
1523
2342
|
}
|
|
2343
|
+
async emitIntentObservers(bindings, context) {
|
|
2344
|
+
if (!this.observerDispatcher || bindings.length === 0)
|
|
2345
|
+
return;
|
|
2346
|
+
await this.observerDispatcher.dispatch(bindings, context);
|
|
2347
|
+
}
|
|
1524
2348
|
async runIntentSensors(sensorClasses, intent, frame) {
|
|
1525
2349
|
if (!this.moduleRef)
|
|
1526
2350
|
return;
|
|
@@ -1549,6 +2373,226 @@ var require_intent_router = __commonJS({
|
|
|
1549
2373
|
}
|
|
1550
2374
|
}
|
|
1551
2375
|
}
|
|
2376
|
+
getEffectiveCapsulePolicy(intent, frame) {
|
|
2377
|
+
const registeredPolicy = this.intentCapsulePolicies.get(intent);
|
|
2378
|
+
const chainConfig = this.intentChains.get(intent);
|
|
2379
|
+
const executionContext = (0, axis_execution_context_1.getAxisExecutionContext)(frame);
|
|
2380
|
+
const derivedScopes = Array.from(/* @__PURE__ */ new Set([
|
|
2381
|
+
...this.toScopeList(chainConfig?.capsuleScope),
|
|
2382
|
+
...this.toScopeList(executionContext?.capsuleRef?.scope),
|
|
2383
|
+
...this.toScopeList(executionContext?.chainStep?.capsuleScope)
|
|
2384
|
+
]));
|
|
2385
|
+
const requiresCapsule = chainConfig?.proofRequired || executionContext?.capsuleRef?.proofRequired || executionContext?.chainStep?.proofRequired || executionContext?.chainEnvelope?.capsule?.proofRequired || derivedScopes.length > 0;
|
|
2386
|
+
const derivedPolicy = requiresCapsule ? (0, capsule_policy_decorator_1.normalizeCapsulePolicyOptions)({
|
|
2387
|
+
required: true,
|
|
2388
|
+
scopes: derivedScopes.length > 0 ? derivedScopes : void 0
|
|
2389
|
+
}) : void 0;
|
|
2390
|
+
return (0, capsule_policy_decorator_1.mergeCapsulePolicyOptions)(registeredPolicy, derivedPolicy);
|
|
2391
|
+
}
|
|
2392
|
+
enforceCapsulePolicy(intent, frame, body, policy) {
|
|
2393
|
+
const executionContext = (0, axis_execution_context_1.getAxisExecutionContext)(frame);
|
|
2394
|
+
const inlineCapsuleRecord = this.toInlineCapsuleRecord(executionContext?.inlineCapsule);
|
|
2395
|
+
const inlineCapsule = (0, inline_capsule_1.normalizeInlineCapsule)(inlineCapsuleRecord);
|
|
2396
|
+
const normalizedPolicy = policy ? (0, capsule_policy_decorator_1.normalizeCapsulePolicyOptions)(policy) : void 0;
|
|
2397
|
+
if (!inlineCapsule) {
|
|
2398
|
+
if (normalizedPolicy?.required) {
|
|
2399
|
+
if (normalizedPolicy.allowCapsuleRef && this.hasCapsuleReference(frame) && this.toScopeList(normalizedPolicy.scopes).length === 0 && normalizedPolicy.intentBound === false) {
|
|
2400
|
+
return;
|
|
2401
|
+
}
|
|
2402
|
+
throw new axis_error_1.AxisError(this.hasCapsuleReference(frame) ? "CAPSULE_CLAIMS_REQUIRED" : "CAPSULE_REQUIRED", `Intent ${intent} requires an inline capsule for policy enforcement`, 403, { intent });
|
|
2403
|
+
}
|
|
2404
|
+
return;
|
|
2405
|
+
}
|
|
2406
|
+
if ((0, inline_capsule_1.isInlineCapsuleExpired)(inlineCapsule)) {
|
|
2407
|
+
throw new axis_error_1.AxisError("CAPSULE_EXPIRED", `Capsule for ${intent} is expired`, 403, { intent, capsuleId: inlineCapsule.id });
|
|
2408
|
+
}
|
|
2409
|
+
const actorId = this.getActorIdFromFrame(frame) || executionContext?.actorId;
|
|
2410
|
+
if (actorId && inlineCapsule.actorId && !this.identifiersMatch(actorId, inlineCapsule.actorId)) {
|
|
2411
|
+
throw new axis_error_1.AxisError("CAPSULE_ACTOR_MISMATCH", `Capsule actor does not match request actor for ${intent}`, 403, {
|
|
2412
|
+
intent,
|
|
2413
|
+
actorId,
|
|
2414
|
+
capsuleActorId: inlineCapsule.actorId
|
|
2415
|
+
});
|
|
2416
|
+
}
|
|
2417
|
+
const proofRef = this.getProofRefFromFrame(frame);
|
|
2418
|
+
if (proofRef && inlineCapsule.id && !this.identifiersMatch(proofRef, inlineCapsule.id)) {
|
|
2419
|
+
throw new axis_error_1.AxisError("CAPSULE_REF_MISMATCH", `Capsule reference does not match request proof for ${intent}`, 403, {
|
|
2420
|
+
intent,
|
|
2421
|
+
proofRef,
|
|
2422
|
+
capsuleId: inlineCapsule.id
|
|
2423
|
+
});
|
|
2424
|
+
}
|
|
2425
|
+
const realm = this.getHeaderValue(frame, constants_1.TLV_REALM);
|
|
2426
|
+
if (realm && inlineCapsule.realm && realm !== inlineCapsule.realm) {
|
|
2427
|
+
throw new axis_error_1.AxisError("CAPSULE_REALM_MISMATCH", `Capsule realm does not match request realm for ${intent}`, 403, { intent, realm, capsuleRealm: inlineCapsule.realm });
|
|
2428
|
+
}
|
|
2429
|
+
const node = this.getHeaderValue(frame, constants_1.TLV_NODE);
|
|
2430
|
+
if (node && inlineCapsule.node && node !== inlineCapsule.node) {
|
|
2431
|
+
throw new axis_error_1.AxisError("CAPSULE_NODE_MISMATCH", `Capsule node does not match request node for ${intent}`, 403, { intent, node, capsuleNode: inlineCapsule.node });
|
|
2432
|
+
}
|
|
2433
|
+
const shouldCheckIntent = normalizedPolicy?.intentBound ?? true;
|
|
2434
|
+
if (shouldCheckIntent && !(0, inline_capsule_1.inlineCapsuleAllowsIntent)(inlineCapsule, intent)) {
|
|
2435
|
+
throw new axis_error_1.AxisError("CAPSULE_DENIED", `Capsule does not authorize ${intent}`, 403, {
|
|
2436
|
+
intent,
|
|
2437
|
+
capsuleId: inlineCapsule.id,
|
|
2438
|
+
allowedIntents: inlineCapsule.intents
|
|
2439
|
+
});
|
|
2440
|
+
}
|
|
2441
|
+
const requiredScopes = this.toScopeList(normalizedPolicy?.scopes);
|
|
2442
|
+
if (requiredScopes.length === 0) {
|
|
2443
|
+
return;
|
|
2444
|
+
}
|
|
2445
|
+
let resolvedScopes;
|
|
2446
|
+
try {
|
|
2447
|
+
resolvedScopes = (0, inline_capsule_1.resolvePolicyScopes)(requiredScopes, {
|
|
2448
|
+
body,
|
|
2449
|
+
intent,
|
|
2450
|
+
actorId,
|
|
2451
|
+
chainId: executionContext?.chainEnvelope?.chainId,
|
|
2452
|
+
stepId: executionContext?.chainStep?.stepId
|
|
2453
|
+
});
|
|
2454
|
+
} catch (error) {
|
|
2455
|
+
this.logger.error(`Scope template error for ${intent}: ${error.message}`);
|
|
2456
|
+
throw new axis_error_1.AxisError("CAPSULE_SCOPE_TEMPLATE_UNRESOLVED", "Scope policy validation failed", 400, { intent });
|
|
2457
|
+
}
|
|
2458
|
+
if (!(0, inline_capsule_1.inlineCapsuleSatisfiesScopes)(inlineCapsule, resolvedScopes, normalizedPolicy?.scopeMode ?? "all")) {
|
|
2459
|
+
throw new axis_error_1.AxisError("SCOPE_MISMATCH", `Capsule scopes do not satisfy ${intent}`, 403, {
|
|
2460
|
+
intent,
|
|
2461
|
+
requiredScopes: resolvedScopes,
|
|
2462
|
+
availableScopes: inlineCapsule.scopes || []
|
|
2463
|
+
});
|
|
2464
|
+
}
|
|
2465
|
+
}
|
|
2466
|
+
async executeChainRequest(frame, request) {
|
|
2467
|
+
const { AxisChainExecutor: AxisChainExecutor2 } = await Promise.resolve().then(() => __importStar(require_axis_chain_executor()));
|
|
2468
|
+
const headerActorId = this.getActorIdFromFrame(frame);
|
|
2469
|
+
if (request.actorId && headerActorId && !this.identifiersMatch(request.actorId, headerActorId)) {
|
|
2470
|
+
throw new axis_error_1.AxisError("ACTOR_MISMATCH", "CHAIN.EXEC actorId conflicts with authenticated frame identity", 403);
|
|
2471
|
+
}
|
|
2472
|
+
const actorId = headerActorId || request.actorId;
|
|
2473
|
+
const inlineCapsule = this.toInlineCapsuleRecord(request.capsule);
|
|
2474
|
+
const capsuleId = this.extractInlineCapsuleId(inlineCapsule);
|
|
2475
|
+
const headers = new Map(frame.headers);
|
|
2476
|
+
if (capsuleId) {
|
|
2477
|
+
headers.set(constants_1.TLV_CAPSULE, this.encoder.encode(capsuleId));
|
|
2478
|
+
headers.set(constants_1.TLV_PROOF_REF, this.encoder.encode(capsuleId));
|
|
2479
|
+
}
|
|
2480
|
+
const baseFrame = (0, axis_execution_context_1.withAxisExecutionContext)({
|
|
2481
|
+
...frame,
|
|
2482
|
+
headers
|
|
2483
|
+
}, (0, axis_execution_context_1.mergeAxisExecutionContext)((0, axis_execution_context_1.getAxisExecutionContext)(frame), {
|
|
2484
|
+
metaIntent: "CHAIN.EXEC",
|
|
2485
|
+
actorId,
|
|
2486
|
+
inlineCapsule,
|
|
2487
|
+
capsuleRef: request.envelope.capsule,
|
|
2488
|
+
chainEnvelope: request.envelope
|
|
2489
|
+
}) || {});
|
|
2490
|
+
const executor = new AxisChainExecutor2(this, this.observerDispatcher);
|
|
2491
|
+
const result = await executor.execute(request.envelope, {
|
|
2492
|
+
actorId,
|
|
2493
|
+
baseFrame
|
|
2494
|
+
});
|
|
2495
|
+
return {
|
|
2496
|
+
ok: result.status !== "FAILED",
|
|
2497
|
+
effect: "chain.complete",
|
|
2498
|
+
body: this.encodeJson(result),
|
|
2499
|
+
metadata: {
|
|
2500
|
+
chainId: result.chainId,
|
|
2501
|
+
status: result.status
|
|
2502
|
+
}
|
|
2503
|
+
};
|
|
2504
|
+
}
|
|
2505
|
+
parseIntentExecBody(bytes2) {
|
|
2506
|
+
try {
|
|
2507
|
+
return JSON.parse(this.decoder.decode(bytes2));
|
|
2508
|
+
} catch (error) {
|
|
2509
|
+
throw new Error(`INTENT.EXEC unwrapping failed: ${error.message}`);
|
|
2510
|
+
}
|
|
2511
|
+
}
|
|
2512
|
+
parseChainRequestBody(bytes2) {
|
|
2513
|
+
let jsonError;
|
|
2514
|
+
try {
|
|
2515
|
+
const parsed = JSON.parse(this.decoder.decode(bytes2));
|
|
2516
|
+
if (this.isChainRequestLike(parsed)) {
|
|
2517
|
+
return {
|
|
2518
|
+
envelope: parsed.envelope,
|
|
2519
|
+
capsule: this.toInlineCapsuleRecord(parsed.capsule),
|
|
2520
|
+
actorId: typeof parsed.actorId === "string" ? parsed.actorId : void 0
|
|
2521
|
+
};
|
|
2522
|
+
}
|
|
2523
|
+
if (this.isChainEnvelopeLike(parsed)) {
|
|
2524
|
+
return { envelope: parsed };
|
|
2525
|
+
}
|
|
2526
|
+
} catch (error) {
|
|
2527
|
+
jsonError = error;
|
|
2528
|
+
}
|
|
2529
|
+
try {
|
|
2530
|
+
const decoded = (0, axis_protocol_1.decodeChainRequest)(bytes2);
|
|
2531
|
+
return {
|
|
2532
|
+
envelope: decoded.envelope,
|
|
2533
|
+
capsule: this.toInlineCapsuleRecord(decoded.capsule),
|
|
2534
|
+
actorId: decoded.actorId
|
|
2535
|
+
};
|
|
2536
|
+
} catch (requestError) {
|
|
2537
|
+
try {
|
|
2538
|
+
return {
|
|
2539
|
+
envelope: (0, axis_protocol_1.decodeChainEnvelope)(bytes2)
|
|
2540
|
+
};
|
|
2541
|
+
} catch (envelopeError) {
|
|
2542
|
+
const reason = [jsonError?.message, requestError.message, envelopeError.message].filter(Boolean).join(" | ");
|
|
2543
|
+
throw new Error(`CHAIN.EXEC decode failed: ${reason}`);
|
|
2544
|
+
}
|
|
2545
|
+
}
|
|
2546
|
+
}
|
|
2547
|
+
isChainRequestLike(value) {
|
|
2548
|
+
return !!value && typeof value === "object" && "envelope" in value && this.isChainEnvelopeLike(value.envelope);
|
|
2549
|
+
}
|
|
2550
|
+
isChainEnvelopeLike(value) {
|
|
2551
|
+
return !!value && typeof value === "object" && typeof value.chainId === "string" && Array.isArray(value.steps);
|
|
2552
|
+
}
|
|
2553
|
+
encodeJson(value) {
|
|
2554
|
+
return this.encoder.encode(JSON.stringify(value));
|
|
2555
|
+
}
|
|
2556
|
+
getActorIdFromFrame(frame) {
|
|
2557
|
+
return this.getHeaderValue(frame, constants_1.TLV_ACTOR_ID);
|
|
2558
|
+
}
|
|
2559
|
+
getProofRefFromFrame(frame) {
|
|
2560
|
+
return this.getHeaderValue(frame, constants_1.TLV_PROOF_REF) || this.getHeaderValue(frame, constants_1.TLV_CAPSULE);
|
|
2561
|
+
}
|
|
2562
|
+
hasCapsuleReference(frame) {
|
|
2563
|
+
return !!this.getProofRefFromFrame(frame);
|
|
2564
|
+
}
|
|
2565
|
+
getHeaderValue(frame, tag) {
|
|
2566
|
+
const value = frame.headers.get(tag);
|
|
2567
|
+
if (!value || value.length === 0) {
|
|
2568
|
+
return void 0;
|
|
2569
|
+
}
|
|
2570
|
+
const decoded = this.decoder.decode(value);
|
|
2571
|
+
if (/^[\x20-\x7e]+$/.test(decoded)) {
|
|
2572
|
+
return decoded;
|
|
2573
|
+
}
|
|
2574
|
+
return Buffer.from(value).toString("hex");
|
|
2575
|
+
}
|
|
2576
|
+
identifiersMatch(left, right) {
|
|
2577
|
+
const normalize2 = (value) => /^[0-9a-f]+$/i.test(value) ? value.toLowerCase() : value;
|
|
2578
|
+
return normalize2(left) === normalize2(right);
|
|
2579
|
+
}
|
|
2580
|
+
extractInlineCapsuleId(capsule) {
|
|
2581
|
+
const id = capsule?.id;
|
|
2582
|
+
return typeof id === "string" && id.length > 0 ? id : void 0;
|
|
2583
|
+
}
|
|
2584
|
+
toInlineCapsuleRecord(value) {
|
|
2585
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
2586
|
+
return void 0;
|
|
2587
|
+
}
|
|
2588
|
+
return value;
|
|
2589
|
+
}
|
|
2590
|
+
toScopeList(value) {
|
|
2591
|
+
if (!value) {
|
|
2592
|
+
return [];
|
|
2593
|
+
}
|
|
2594
|
+
return Array.isArray(value) ? value : [value];
|
|
2595
|
+
}
|
|
1552
2596
|
configureCce(config) {
|
|
1553
2597
|
this.ccePipelineConfig = config;
|
|
1554
2598
|
this.logger.log("CCE pipeline configured");
|
|
@@ -1622,23 +2666,460 @@ var require_intent_router = __commonJS({
|
|
|
1622
2666
|
scope: f.scope
|
|
1623
2667
|
}))
|
|
1624
2668
|
};
|
|
1625
|
-
this.intentSchemas.set(meta.intent, schema);
|
|
2669
|
+
this.intentSchemas.set(meta.intent, schema);
|
|
2670
|
+
}
|
|
2671
|
+
};
|
|
2672
|
+
exports.IntentRouter = IntentRouter2;
|
|
2673
|
+
IntentRouter2.BUILTIN_INTENTS = /* @__PURE__ */ new Set([
|
|
2674
|
+
"system.ping",
|
|
2675
|
+
"public.ping",
|
|
2676
|
+
"system.time",
|
|
2677
|
+
"system.echo",
|
|
2678
|
+
"CHAIN.EXEC",
|
|
2679
|
+
"axis.chain.exec",
|
|
2680
|
+
"INTENT.EXEC",
|
|
2681
|
+
"axis.intent.exec"
|
|
2682
|
+
]);
|
|
2683
|
+
exports.IntentRouter = IntentRouter2 = IntentRouter_1 = __decorate([
|
|
2684
|
+
(0, common_1.Injectable)(),
|
|
2685
|
+
__param(0, (0, common_1.Optional)()),
|
|
2686
|
+
__param(1, (0, common_1.Optional)()),
|
|
2687
|
+
__metadata("design:paramtypes", [typeof (_a = typeof core_1.ModuleRef !== "undefined" && core_1.ModuleRef) === "function" ? _a : Object, typeof (_b = typeof observer_dispatcher_service_1.ObserverDispatcherService !== "undefined" && observer_dispatcher_service_1.ObserverDispatcherService) === "function" ? _b : Object])
|
|
2688
|
+
], IntentRouter2);
|
|
2689
|
+
}
|
|
2690
|
+
});
|
|
2691
|
+
|
|
2692
|
+
// src/engine/axis-chain.executor.ts
|
|
2693
|
+
var require_axis_chain_executor = __commonJS({
|
|
2694
|
+
"src/engine/axis-chain.executor.ts"(exports) {
|
|
2695
|
+
"use strict";
|
|
2696
|
+
var __decorate = exports && exports.__decorate || function(decorators, target, key, desc) {
|
|
2697
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2698
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
2699
|
+
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;
|
|
2700
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2701
|
+
};
|
|
2702
|
+
var __metadata = exports && exports.__metadata || function(k, v) {
|
|
2703
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
2704
|
+
};
|
|
2705
|
+
var __param = exports && exports.__param || function(paramIndex, decorator) {
|
|
2706
|
+
return function(target, key) {
|
|
2707
|
+
decorator(target, key, paramIndex);
|
|
2708
|
+
};
|
|
2709
|
+
};
|
|
2710
|
+
var AxisChainExecutor_1;
|
|
2711
|
+
var _a;
|
|
2712
|
+
var _b;
|
|
2713
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2714
|
+
exports.AxisChainExecutor = void 0;
|
|
2715
|
+
var crypto_1 = __require("crypto");
|
|
2716
|
+
var common_1 = __require("@nestjs/common");
|
|
2717
|
+
var constants_1 = (init_constants(), __toCommonJS(constants_exports));
|
|
2718
|
+
var axis_execution_context_1 = (init_axis_execution_context(), __toCommonJS(axis_execution_context_exports));
|
|
2719
|
+
var observer_dispatcher_service_1 = require_observer_dispatcher_service();
|
|
2720
|
+
var intent_router_1 = require_intent_router();
|
|
2721
|
+
var AxisChainExecutor2 = AxisChainExecutor_1 = class AxisChainExecutor {
|
|
2722
|
+
constructor(router, observerDispatcher) {
|
|
2723
|
+
this.router = router;
|
|
2724
|
+
this.observerDispatcher = observerDispatcher;
|
|
2725
|
+
this.logger = new common_1.Logger(AxisChainExecutor_1.name);
|
|
2726
|
+
this.encoder = new TextEncoder();
|
|
2727
|
+
this.decoder = new TextDecoder();
|
|
2728
|
+
}
|
|
2729
|
+
async execute(envelope, options = {}) {
|
|
2730
|
+
this.validateEnvelope(envelope);
|
|
2731
|
+
const startedAt = Date.now();
|
|
2732
|
+
const results = /* @__PURE__ */ new Map();
|
|
2733
|
+
const bindings = this.collectChainBindings(envelope);
|
|
2734
|
+
await this.dispatch(bindings, {
|
|
2735
|
+
event: "chain.received",
|
|
2736
|
+
timestamp: startedAt,
|
|
2737
|
+
chainId: envelope.chainId,
|
|
2738
|
+
envelope,
|
|
2739
|
+
observerTags: envelope.observerTags,
|
|
2740
|
+
capsule: envelope.capsule,
|
|
2741
|
+
keyExchange: envelope.keyExchange
|
|
2742
|
+
});
|
|
2743
|
+
await this.dispatch(bindings, {
|
|
2744
|
+
event: "chain.admitted",
|
|
2745
|
+
timestamp: Date.now(),
|
|
2746
|
+
chainId: envelope.chainId,
|
|
2747
|
+
envelope,
|
|
2748
|
+
observerTags: envelope.observerTags,
|
|
2749
|
+
capsule: envelope.capsule,
|
|
2750
|
+
keyExchange: envelope.keyExchange
|
|
2751
|
+
});
|
|
2752
|
+
const stepsById = new Map(envelope.steps.map((step) => [step.stepId, step]));
|
|
2753
|
+
const pending = new Set(stepsById.keys());
|
|
2754
|
+
while (pending.size > 0) {
|
|
2755
|
+
const ready = Array.from(pending).map((stepId) => stepsById.get(stepId)).filter((step) => this.canRun(step, results));
|
|
2756
|
+
if (ready.length === 0) {
|
|
2757
|
+
this.markUnresolvedSteps(pending, stepsById, results, "BLOCKED", "UNRESOLVED_DEPENDENCIES");
|
|
2758
|
+
break;
|
|
2759
|
+
}
|
|
2760
|
+
if (envelope.mode === "parallel") {
|
|
2761
|
+
const waveResults = await Promise.all(ready.map((step) => this.executeStep(step, envelope, results, options)));
|
|
2762
|
+
for (const result of waveResults) {
|
|
2763
|
+
results.set(result.stepId, result);
|
|
2764
|
+
pending.delete(result.stepId);
|
|
2765
|
+
}
|
|
2766
|
+
} else {
|
|
2767
|
+
for (const step of ready) {
|
|
2768
|
+
const result = await this.executeStep(step, envelope, results, options);
|
|
2769
|
+
results.set(result.stepId, result);
|
|
2770
|
+
pending.delete(result.stepId);
|
|
2771
|
+
if (result.status === "FAILED" && (envelope.mode === "strict" || envelope.mode === "atomic")) {
|
|
2772
|
+
this.markUnresolvedSteps(pending, stepsById, results, "SKIPPED", "CHAIN_HALTED");
|
|
2773
|
+
pending.clear();
|
|
2774
|
+
break;
|
|
2775
|
+
}
|
|
2776
|
+
}
|
|
2777
|
+
}
|
|
2778
|
+
this.blockStepsWithFailedDependencies(pending, stepsById, results);
|
|
2779
|
+
}
|
|
2780
|
+
const finishedAt = Date.now();
|
|
2781
|
+
const orderedResults = envelope.steps.map((step) => results.get(step.stepId));
|
|
2782
|
+
const summary = this.buildSummary(envelope.mode, orderedResults, startedAt, finishedAt, envelope.chainId);
|
|
2783
|
+
await this.dispatch(bindings, {
|
|
2784
|
+
event: summary.status === "SUCCEEDED" ? "chain.completed" : summary.status === "PARTIAL" ? "chain.partial" : "chain.failed",
|
|
2785
|
+
timestamp: finishedAt,
|
|
2786
|
+
chainId: envelope.chainId,
|
|
2787
|
+
envelope,
|
|
2788
|
+
result: summary,
|
|
2789
|
+
observerTags: envelope.observerTags,
|
|
2790
|
+
capsule: envelope.capsule,
|
|
2791
|
+
keyExchange: envelope.keyExchange
|
|
2792
|
+
});
|
|
2793
|
+
return summary;
|
|
2794
|
+
}
|
|
2795
|
+
async executeStep(step, envelope, results, options) {
|
|
2796
|
+
const stepBindings = this.router.getObservers(step.intent);
|
|
2797
|
+
const startedAt = Date.now();
|
|
2798
|
+
const input = this.resolveStepInput(step.input, results);
|
|
2799
|
+
await this.dispatch(stepBindings, {
|
|
2800
|
+
event: "step.started",
|
|
2801
|
+
timestamp: startedAt,
|
|
2802
|
+
chainId: envelope.chainId,
|
|
2803
|
+
stepId: step.stepId,
|
|
2804
|
+
intent: step.intent,
|
|
2805
|
+
envelope,
|
|
2806
|
+
step,
|
|
2807
|
+
observerTags: [...envelope.observerTags || [], ...step.observerTags || []],
|
|
2808
|
+
capsule: step.capsuleScope ? {
|
|
2809
|
+
...envelope.capsule,
|
|
2810
|
+
scope: step.capsuleScope
|
|
2811
|
+
} : envelope.capsule,
|
|
2812
|
+
keyExchange: step.keyExchange || envelope.keyExchange
|
|
2813
|
+
});
|
|
2814
|
+
try {
|
|
2815
|
+
const frame = this.buildFrame(step, envelope, input, options);
|
|
2816
|
+
const effect = await this.router.route(frame);
|
|
2817
|
+
const finishedAt = Date.now();
|
|
2818
|
+
const output = this.decodeOutput(effect.body);
|
|
2819
|
+
const proofHash = this.computeProofHash(envelope.chainId, step.stepId, effect, output);
|
|
2820
|
+
const result = {
|
|
2821
|
+
stepId: step.stepId,
|
|
2822
|
+
intent: step.intent,
|
|
2823
|
+
status: "SUCCEEDED",
|
|
2824
|
+
effect: effect.effect,
|
|
2825
|
+
output,
|
|
2826
|
+
dependsOn: step.dependsOn,
|
|
2827
|
+
startedAt,
|
|
2828
|
+
finishedAt,
|
|
2829
|
+
proofHash,
|
|
2830
|
+
observerTags: [...envelope.observerTags || [], ...step.observerTags || []],
|
|
2831
|
+
metadata: effect.metadata
|
|
2832
|
+
};
|
|
2833
|
+
await this.dispatch(stepBindings, {
|
|
2834
|
+
event: "handler.completed",
|
|
2835
|
+
timestamp: finishedAt,
|
|
2836
|
+
chainId: envelope.chainId,
|
|
2837
|
+
stepId: step.stepId,
|
|
2838
|
+
intent: step.intent,
|
|
2839
|
+
effect,
|
|
2840
|
+
envelope,
|
|
2841
|
+
step,
|
|
2842
|
+
result,
|
|
2843
|
+
observerTags: result.observerTags,
|
|
2844
|
+
capsule: envelope.capsule,
|
|
2845
|
+
keyExchange: step.keyExchange || envelope.keyExchange
|
|
2846
|
+
});
|
|
2847
|
+
await this.dispatch(stepBindings, {
|
|
2848
|
+
event: "proof.recorded",
|
|
2849
|
+
timestamp: finishedAt,
|
|
2850
|
+
chainId: envelope.chainId,
|
|
2851
|
+
stepId: step.stepId,
|
|
2852
|
+
intent: step.intent,
|
|
2853
|
+
envelope,
|
|
2854
|
+
step,
|
|
2855
|
+
result,
|
|
2856
|
+
observerTags: result.observerTags,
|
|
2857
|
+
capsule: envelope.capsule,
|
|
2858
|
+
keyExchange: step.keyExchange || envelope.keyExchange,
|
|
2859
|
+
metadata: { proofHash }
|
|
2860
|
+
});
|
|
2861
|
+
await this.dispatch(stepBindings, {
|
|
2862
|
+
event: "step.completed",
|
|
2863
|
+
timestamp: finishedAt,
|
|
2864
|
+
chainId: envelope.chainId,
|
|
2865
|
+
stepId: step.stepId,
|
|
2866
|
+
intent: step.intent,
|
|
2867
|
+
effect,
|
|
2868
|
+
envelope,
|
|
2869
|
+
step,
|
|
2870
|
+
result,
|
|
2871
|
+
observerTags: result.observerTags,
|
|
2872
|
+
capsule: envelope.capsule,
|
|
2873
|
+
keyExchange: step.keyExchange || envelope.keyExchange
|
|
2874
|
+
});
|
|
2875
|
+
return result;
|
|
2876
|
+
} catch (error) {
|
|
2877
|
+
const finishedAt = Date.now();
|
|
2878
|
+
const result = {
|
|
2879
|
+
stepId: step.stepId,
|
|
2880
|
+
intent: step.intent,
|
|
2881
|
+
status: "FAILED",
|
|
2882
|
+
error: error.message,
|
|
2883
|
+
dependsOn: step.dependsOn,
|
|
2884
|
+
startedAt,
|
|
2885
|
+
finishedAt,
|
|
2886
|
+
observerTags: [...envelope.observerTags || [], ...step.observerTags || []]
|
|
2887
|
+
};
|
|
2888
|
+
this.logger.warn(`Chain ${envelope.chainId} step ${step.stepId} failed: ${error.message}`);
|
|
2889
|
+
await this.dispatch(stepBindings, {
|
|
2890
|
+
event: "step.failed",
|
|
2891
|
+
timestamp: finishedAt,
|
|
2892
|
+
chainId: envelope.chainId,
|
|
2893
|
+
stepId: step.stepId,
|
|
2894
|
+
intent: step.intent,
|
|
2895
|
+
error: error.message,
|
|
2896
|
+
envelope,
|
|
2897
|
+
step,
|
|
2898
|
+
result,
|
|
2899
|
+
observerTags: result.observerTags,
|
|
2900
|
+
capsule: envelope.capsule,
|
|
2901
|
+
keyExchange: step.keyExchange || envelope.keyExchange
|
|
2902
|
+
});
|
|
2903
|
+
return result;
|
|
2904
|
+
}
|
|
2905
|
+
}
|
|
2906
|
+
buildFrame(step, envelope, input, options) {
|
|
2907
|
+
const baseContext = (0, axis_execution_context_1.getAxisExecutionContext)(options.baseFrame);
|
|
2908
|
+
const baseHeaders = new Map(options.baseFrame?.headers || []);
|
|
2909
|
+
baseHeaders.set(constants_1.TLV_INTENT, this.encoder.encode(step.intent));
|
|
2910
|
+
baseHeaders.set(constants_1.TLV_TRACE_ID, this.encoder.encode(envelope.chainId));
|
|
2911
|
+
const capsuleId = envelope.capsule?.capsuleId;
|
|
2912
|
+
if (capsuleId) {
|
|
2913
|
+
baseHeaders.set(constants_1.TLV_CAPSULE, this.encoder.encode(capsuleId));
|
|
2914
|
+
}
|
|
2915
|
+
if (options.actorId) {
|
|
2916
|
+
baseHeaders.set(constants_1.TLV_ACTOR_ID, this.encoder.encode(options.actorId));
|
|
2917
|
+
}
|
|
2918
|
+
return (0, axis_execution_context_1.withAxisExecutionContext)({
|
|
2919
|
+
flags: (options.baseFrame?.flags || 0) | constants_1.FLAG_CHAIN_REQ,
|
|
2920
|
+
headers: baseHeaders,
|
|
2921
|
+
body: this.serializeInput(input),
|
|
2922
|
+
sig: options.baseFrame?.sig || new Uint8Array(0)
|
|
2923
|
+
}, (0, axis_execution_context_1.mergeAxisExecutionContext)(baseContext, {
|
|
2924
|
+
metaIntent: "CHAIN.EXEC",
|
|
2925
|
+
actorId: options.actorId || baseContext?.actorId,
|
|
2926
|
+
capsuleRef: step.capsuleScope ? {
|
|
2927
|
+
...envelope.capsule || {},
|
|
2928
|
+
scope: step.capsuleScope
|
|
2929
|
+
} : envelope.capsule,
|
|
2930
|
+
chainEnvelope: envelope,
|
|
2931
|
+
chainStep: step
|
|
2932
|
+
}) || {});
|
|
2933
|
+
}
|
|
2934
|
+
validateEnvelope(envelope) {
|
|
2935
|
+
if (!envelope.chainId) {
|
|
2936
|
+
throw new Error("CHAIN_ID_REQUIRED");
|
|
2937
|
+
}
|
|
2938
|
+
if (!envelope.steps || envelope.steps.length === 0) {
|
|
2939
|
+
throw new Error("CHAIN_STEPS_REQUIRED");
|
|
2940
|
+
}
|
|
2941
|
+
const seen = /* @__PURE__ */ new Set();
|
|
2942
|
+
for (const step of envelope.steps) {
|
|
2943
|
+
if (!step.stepId) {
|
|
2944
|
+
throw new Error("CHAIN_STEP_ID_REQUIRED");
|
|
2945
|
+
}
|
|
2946
|
+
if (!step.intent) {
|
|
2947
|
+
throw new Error(`CHAIN_STEP_INTENT_REQUIRED:${step.stepId}`);
|
|
2948
|
+
}
|
|
2949
|
+
if (seen.has(step.stepId)) {
|
|
2950
|
+
throw new Error(`CHAIN_STEP_DUPLICATE:${step.stepId}`);
|
|
2951
|
+
}
|
|
2952
|
+
seen.add(step.stepId);
|
|
2953
|
+
}
|
|
2954
|
+
for (const step of envelope.steps) {
|
|
2955
|
+
for (const dependency of step.dependsOn || []) {
|
|
2956
|
+
if (!seen.has(dependency)) {
|
|
2957
|
+
throw new Error(`CHAIN_STEP_DEPENDENCY_UNKNOWN:${step.stepId}:${dependency}`);
|
|
2958
|
+
}
|
|
2959
|
+
}
|
|
2960
|
+
}
|
|
2961
|
+
}
|
|
2962
|
+
canRun(step, results) {
|
|
2963
|
+
return (step.dependsOn || []).every((dependency) => results.has(dependency));
|
|
2964
|
+
}
|
|
2965
|
+
blockStepsWithFailedDependencies(pending, stepsById, results) {
|
|
2966
|
+
for (const stepId of Array.from(pending)) {
|
|
2967
|
+
const step = stepsById.get(stepId);
|
|
2968
|
+
if (!step || !step.dependsOn || step.dependsOn.length === 0)
|
|
2969
|
+
continue;
|
|
2970
|
+
const dependencyResults = step.dependsOn.map((dependency) => results.get(dependency)).filter(Boolean);
|
|
2971
|
+
if (dependencyResults.length !== step.dependsOn.length)
|
|
2972
|
+
continue;
|
|
2973
|
+
const hasFailure = dependencyResults.some((dependency) => dependency.status !== "SUCCEEDED");
|
|
2974
|
+
if (!hasFailure)
|
|
2975
|
+
continue;
|
|
2976
|
+
results.set(step.stepId, {
|
|
2977
|
+
stepId: step.stepId,
|
|
2978
|
+
intent: step.intent,
|
|
2979
|
+
status: "BLOCKED",
|
|
2980
|
+
error: "DEPENDENCY_FAILED",
|
|
2981
|
+
dependsOn: step.dependsOn,
|
|
2982
|
+
startedAt: Date.now(),
|
|
2983
|
+
finishedAt: Date.now(),
|
|
2984
|
+
observerTags: step.observerTags
|
|
2985
|
+
});
|
|
2986
|
+
pending.delete(step.stepId);
|
|
2987
|
+
}
|
|
2988
|
+
}
|
|
2989
|
+
markUnresolvedSteps(pending, stepsById, results, status, error) {
|
|
2990
|
+
for (const stepId of pending) {
|
|
2991
|
+
const step = stepsById.get(stepId);
|
|
2992
|
+
if (!step)
|
|
2993
|
+
continue;
|
|
2994
|
+
results.set(stepId, {
|
|
2995
|
+
stepId,
|
|
2996
|
+
intent: step.intent,
|
|
2997
|
+
status,
|
|
2998
|
+
error,
|
|
2999
|
+
dependsOn: step.dependsOn,
|
|
3000
|
+
startedAt: Date.now(),
|
|
3001
|
+
finishedAt: Date.now(),
|
|
3002
|
+
observerTags: step.observerTags
|
|
3003
|
+
});
|
|
3004
|
+
}
|
|
3005
|
+
}
|
|
3006
|
+
buildSummary(mode, results, startedAt, finishedAt, chainId) {
|
|
3007
|
+
const completedSteps = results.filter((result) => result.status === "SUCCEEDED").length;
|
|
3008
|
+
const failedSteps = results.filter((result) => result.status === "FAILED").length;
|
|
3009
|
+
const blockedSteps = results.filter((result) => result.status === "BLOCKED").length;
|
|
3010
|
+
const skippedSteps = results.filter((result) => result.status === "SKIPPED").length;
|
|
3011
|
+
let status = "SUCCEEDED";
|
|
3012
|
+
if (failedSteps > 0 || blockedSteps > 0 || skippedSteps > 0) {
|
|
3013
|
+
status = mode === "best_effort" || mode === "parallel" ? completedSteps > 0 ? "PARTIAL" : "FAILED" : "FAILED";
|
|
3014
|
+
}
|
|
3015
|
+
return {
|
|
3016
|
+
chainId,
|
|
3017
|
+
mode,
|
|
3018
|
+
status,
|
|
3019
|
+
completedSteps,
|
|
3020
|
+
failedSteps,
|
|
3021
|
+
blockedSteps,
|
|
3022
|
+
skippedSteps,
|
|
3023
|
+
startedAt,
|
|
3024
|
+
finishedAt,
|
|
3025
|
+
results,
|
|
3026
|
+
rollback: mode === "atomic" ? {
|
|
3027
|
+
supported: false,
|
|
3028
|
+
attempted: false,
|
|
3029
|
+
reason: "AXIS handlers do not expose rollback semantics yet"
|
|
3030
|
+
} : void 0
|
|
3031
|
+
};
|
|
3032
|
+
}
|
|
3033
|
+
resolveStepInput(value, results) {
|
|
3034
|
+
if (typeof value === "string") {
|
|
3035
|
+
if (!value.startsWith("$"))
|
|
3036
|
+
return value;
|
|
3037
|
+
return this.lookupReference(value.slice(1), results);
|
|
3038
|
+
}
|
|
3039
|
+
if (Array.isArray(value)) {
|
|
3040
|
+
return value.map((entry) => this.resolveStepInput(entry, results));
|
|
3041
|
+
}
|
|
3042
|
+
if (value && typeof value === "object") {
|
|
3043
|
+
return Object.fromEntries(Object.entries(value).map(([key, entry]) => [
|
|
3044
|
+
key,
|
|
3045
|
+
this.resolveStepInput(entry, results)
|
|
3046
|
+
]));
|
|
3047
|
+
}
|
|
3048
|
+
return value;
|
|
3049
|
+
}
|
|
3050
|
+
lookupReference(path2, results) {
|
|
3051
|
+
const [stepId, ...segments] = path2.split(".");
|
|
3052
|
+
const result = results.get(stepId);
|
|
3053
|
+
if (!result)
|
|
3054
|
+
return void 0;
|
|
3055
|
+
let current = result;
|
|
3056
|
+
for (const segment of segments) {
|
|
3057
|
+
if (current === void 0 || current === null)
|
|
3058
|
+
return void 0;
|
|
3059
|
+
if (typeof current !== "object")
|
|
3060
|
+
return void 0;
|
|
3061
|
+
current = current[segment];
|
|
3062
|
+
}
|
|
3063
|
+
return current;
|
|
3064
|
+
}
|
|
3065
|
+
serializeInput(input) {
|
|
3066
|
+
if (input instanceof Uint8Array)
|
|
3067
|
+
return input;
|
|
3068
|
+
if (typeof input === "string")
|
|
3069
|
+
return this.encoder.encode(input);
|
|
3070
|
+
if (input === void 0)
|
|
3071
|
+
return new Uint8Array(0);
|
|
3072
|
+
return this.encoder.encode(JSON.stringify(input));
|
|
3073
|
+
}
|
|
3074
|
+
decodeOutput(body) {
|
|
3075
|
+
if (!body || body.length === 0)
|
|
3076
|
+
return void 0;
|
|
3077
|
+
try {
|
|
3078
|
+
const text = this.decoder.decode(body);
|
|
3079
|
+
try {
|
|
3080
|
+
return JSON.parse(text);
|
|
3081
|
+
} catch {
|
|
3082
|
+
return /^[\x20-\x7E\s]+$/.test(text) ? text : body;
|
|
3083
|
+
}
|
|
3084
|
+
} catch {
|
|
3085
|
+
return body;
|
|
3086
|
+
}
|
|
3087
|
+
}
|
|
3088
|
+
computeProofHash(chainId, stepId, effect, output) {
|
|
3089
|
+
const hash = (0, crypto_1.createHash)("sha256");
|
|
3090
|
+
hash.update(chainId);
|
|
3091
|
+
hash.update(":");
|
|
3092
|
+
hash.update(stepId);
|
|
3093
|
+
hash.update(":");
|
|
3094
|
+
hash.update(effect.effect);
|
|
3095
|
+
hash.update(":");
|
|
3096
|
+
hash.update(JSON.stringify(output ?? null));
|
|
3097
|
+
return hash.digest("hex");
|
|
3098
|
+
}
|
|
3099
|
+
collectChainBindings(envelope) {
|
|
3100
|
+
const uniqueBindings = /* @__PURE__ */ new Map();
|
|
3101
|
+
for (const step of envelope.steps) {
|
|
3102
|
+
for (const binding of this.router.getObservers(step.intent)) {
|
|
3103
|
+
const key = binding.refs.map((ref) => String(ref)).sort().join("|");
|
|
3104
|
+
if (!uniqueBindings.has(key)) {
|
|
3105
|
+
uniqueBindings.set(key, binding);
|
|
3106
|
+
}
|
|
3107
|
+
}
|
|
3108
|
+
}
|
|
3109
|
+
return Array.from(uniqueBindings.values());
|
|
3110
|
+
}
|
|
3111
|
+
async dispatch(bindings, context) {
|
|
3112
|
+
if (!this.observerDispatcher)
|
|
3113
|
+
return;
|
|
3114
|
+
await this.observerDispatcher.dispatch(bindings, context);
|
|
1626
3115
|
}
|
|
1627
3116
|
};
|
|
1628
|
-
exports.
|
|
1629
|
-
|
|
1630
|
-
"system.ping",
|
|
1631
|
-
"public.ping",
|
|
1632
|
-
"system.time",
|
|
1633
|
-
"system.echo",
|
|
1634
|
-
"INTENT.EXEC",
|
|
1635
|
-
"axis.intent.exec"
|
|
1636
|
-
]);
|
|
1637
|
-
exports.IntentRouter = IntentRouter2 = IntentRouter_1 = __decorate([
|
|
3117
|
+
exports.AxisChainExecutor = AxisChainExecutor2;
|
|
3118
|
+
exports.AxisChainExecutor = AxisChainExecutor2 = AxisChainExecutor_1 = __decorate([
|
|
1638
3119
|
(0, common_1.Injectable)(),
|
|
1639
|
-
__param(
|
|
1640
|
-
__metadata("design:paramtypes", [typeof (_a = typeof
|
|
1641
|
-
],
|
|
3120
|
+
__param(1, (0, common_1.Optional)()),
|
|
3121
|
+
__metadata("design:paramtypes", [typeof (_a = typeof intent_router_1.IntentRouter !== "undefined" && intent_router_1.IntentRouter) === "function" ? _a : Object, typeof (_b = typeof observer_dispatcher_service_1.ObserverDispatcherService !== "undefined" && observer_dispatcher_service_1.ObserverDispatcherService) === "function" ? _b : Object])
|
|
3122
|
+
], AxisChainExecutor2);
|
|
1642
3123
|
}
|
|
1643
3124
|
});
|
|
1644
3125
|
|
|
@@ -1841,141 +3322,6 @@ var init_observation_hash = __esm({
|
|
|
1841
3322
|
}
|
|
1842
3323
|
});
|
|
1843
3324
|
|
|
1844
|
-
// src/core/constants.ts
|
|
1845
|
-
var constants_exports = {};
|
|
1846
|
-
__export(constants_exports, {
|
|
1847
|
-
AXIS_MAGIC: () => AXIS_MAGIC,
|
|
1848
|
-
AXIS_VERSION: () => AXIS_VERSION,
|
|
1849
|
-
BodyProfile: () => BodyProfile,
|
|
1850
|
-
ERR_BAD_SIGNATURE: () => ERR_BAD_SIGNATURE,
|
|
1851
|
-
ERR_CONTRACT_VIOLATION: () => ERR_CONTRACT_VIOLATION,
|
|
1852
|
-
ERR_INVALID_PACKET: () => ERR_INVALID_PACKET,
|
|
1853
|
-
ERR_REPLAY_DETECTED: () => ERR_REPLAY_DETECTED,
|
|
1854
|
-
FLAG_BODY_TLV: () => FLAG_BODY_TLV,
|
|
1855
|
-
FLAG_CHAIN_REQ: () => FLAG_CHAIN_REQ,
|
|
1856
|
-
FLAG_HAS_WITNESS: () => FLAG_HAS_WITNESS,
|
|
1857
|
-
MAX_BODY_LEN: () => MAX_BODY_LEN,
|
|
1858
|
-
MAX_FRAME_LEN: () => MAX_FRAME_LEN,
|
|
1859
|
-
MAX_HDR_LEN: () => MAX_HDR_LEN,
|
|
1860
|
-
MAX_SIG_LEN: () => MAX_SIG_LEN,
|
|
1861
|
-
NCERT_ALG: () => NCERT_ALG,
|
|
1862
|
-
NCERT_EXP: () => NCERT_EXP,
|
|
1863
|
-
NCERT_ISSUER_KID: () => NCERT_ISSUER_KID,
|
|
1864
|
-
NCERT_KID: () => NCERT_KID,
|
|
1865
|
-
NCERT_NBF: () => NCERT_NBF,
|
|
1866
|
-
NCERT_NODE_ID: () => NCERT_NODE_ID,
|
|
1867
|
-
NCERT_PAYLOAD: () => NCERT_PAYLOAD,
|
|
1868
|
-
NCERT_PUB: () => NCERT_PUB,
|
|
1869
|
-
NCERT_SCOPE: () => NCERT_SCOPE,
|
|
1870
|
-
NCERT_SIG: () => NCERT_SIG,
|
|
1871
|
-
PROOF_CAPSULE: () => PROOF_CAPSULE,
|
|
1872
|
-
PROOF_JWT: () => PROOF_JWT,
|
|
1873
|
-
PROOF_LOOM: () => PROOF_LOOM,
|
|
1874
|
-
PROOF_MTLS: () => PROOF_MTLS,
|
|
1875
|
-
PROOF_NONE: () => PROOF_NONE,
|
|
1876
|
-
PROOF_WITNESS: () => PROOF_WITNESS,
|
|
1877
|
-
ProofType: () => ProofType,
|
|
1878
|
-
TLV_ACTOR_ID: () => TLV_ACTOR_ID,
|
|
1879
|
-
TLV_AUD: () => TLV_AUD,
|
|
1880
|
-
TLV_BODY_ARR: () => TLV_BODY_ARR,
|
|
1881
|
-
TLV_BODY_OBJ: () => TLV_BODY_OBJ,
|
|
1882
|
-
TLV_CAPSULE: () => TLV_CAPSULE,
|
|
1883
|
-
TLV_EFFECT: () => TLV_EFFECT,
|
|
1884
|
-
TLV_ERROR_CODE: () => TLV_ERROR_CODE,
|
|
1885
|
-
TLV_ERROR_MSG: () => TLV_ERROR_MSG,
|
|
1886
|
-
TLV_INDEX: () => TLV_INDEX,
|
|
1887
|
-
TLV_INTENT: () => TLV_INTENT,
|
|
1888
|
-
TLV_KID: () => TLV_KID,
|
|
1889
|
-
TLV_LOOM_PRESENCE_ID: () => TLV_LOOM_PRESENCE_ID,
|
|
1890
|
-
TLV_LOOM_THREAD_HASH: () => TLV_LOOM_THREAD_HASH,
|
|
1891
|
-
TLV_LOOM_WRIT: () => TLV_LOOM_WRIT,
|
|
1892
|
-
TLV_NODE: () => TLV_NODE,
|
|
1893
|
-
TLV_NODE_CERT_HASH: () => TLV_NODE_CERT_HASH,
|
|
1894
|
-
TLV_NODE_KID: () => TLV_NODE_KID,
|
|
1895
|
-
TLV_NONCE: () => TLV_NONCE,
|
|
1896
|
-
TLV_OFFSET: () => TLV_OFFSET,
|
|
1897
|
-
TLV_OK: () => TLV_OK,
|
|
1898
|
-
TLV_PID: () => TLV_PID,
|
|
1899
|
-
TLV_PREV_HASH: () => TLV_PREV_HASH,
|
|
1900
|
-
TLV_PROOF_REF: () => TLV_PROOF_REF,
|
|
1901
|
-
TLV_PROOF_TYPE: () => TLV_PROOF_TYPE,
|
|
1902
|
-
TLV_REALM: () => TLV_REALM,
|
|
1903
|
-
TLV_RECEIPT_HASH: () => TLV_RECEIPT_HASH,
|
|
1904
|
-
TLV_RID: () => TLV_RID,
|
|
1905
|
-
TLV_SHA256_CHUNK: () => TLV_SHA256_CHUNK,
|
|
1906
|
-
TLV_TRACE_ID: () => TLV_TRACE_ID,
|
|
1907
|
-
TLV_TS: () => TLV_TS,
|
|
1908
|
-
TLV_UPLOAD_ID: () => TLV_UPLOAD_ID
|
|
1909
|
-
});
|
|
1910
|
-
import {
|
|
1911
|
-
AXIS_MAGIC,
|
|
1912
|
-
AXIS_VERSION,
|
|
1913
|
-
MAX_HDR_LEN,
|
|
1914
|
-
MAX_BODY_LEN,
|
|
1915
|
-
MAX_SIG_LEN,
|
|
1916
|
-
MAX_FRAME_LEN,
|
|
1917
|
-
FLAG_BODY_TLV,
|
|
1918
|
-
FLAG_CHAIN_REQ,
|
|
1919
|
-
FLAG_HAS_WITNESS,
|
|
1920
|
-
TLV_PID,
|
|
1921
|
-
TLV_TS,
|
|
1922
|
-
TLV_INTENT,
|
|
1923
|
-
TLV_ACTOR_ID,
|
|
1924
|
-
TLV_PROOF_TYPE,
|
|
1925
|
-
TLV_PROOF_REF,
|
|
1926
|
-
TLV_NONCE,
|
|
1927
|
-
TLV_AUD,
|
|
1928
|
-
TLV_REALM,
|
|
1929
|
-
TLV_NODE,
|
|
1930
|
-
TLV_TRACE_ID,
|
|
1931
|
-
TLV_KID,
|
|
1932
|
-
TLV_RID,
|
|
1933
|
-
TLV_OK,
|
|
1934
|
-
TLV_EFFECT,
|
|
1935
|
-
TLV_ERROR_CODE,
|
|
1936
|
-
TLV_ERROR_MSG,
|
|
1937
|
-
TLV_PREV_HASH,
|
|
1938
|
-
TLV_RECEIPT_HASH,
|
|
1939
|
-
TLV_NODE_KID,
|
|
1940
|
-
TLV_NODE_CERT_HASH,
|
|
1941
|
-
TLV_LOOM_PRESENCE_ID,
|
|
1942
|
-
TLV_LOOM_WRIT,
|
|
1943
|
-
TLV_LOOM_THREAD_HASH,
|
|
1944
|
-
TLV_UPLOAD_ID,
|
|
1945
|
-
TLV_INDEX,
|
|
1946
|
-
TLV_OFFSET,
|
|
1947
|
-
TLV_SHA256_CHUNK,
|
|
1948
|
-
TLV_CAPSULE,
|
|
1949
|
-
TLV_BODY_OBJ,
|
|
1950
|
-
TLV_BODY_ARR,
|
|
1951
|
-
NCERT_NODE_ID,
|
|
1952
|
-
NCERT_KID,
|
|
1953
|
-
NCERT_ALG,
|
|
1954
|
-
NCERT_PUB,
|
|
1955
|
-
NCERT_NBF,
|
|
1956
|
-
NCERT_EXP,
|
|
1957
|
-
NCERT_SCOPE,
|
|
1958
|
-
NCERT_ISSUER_KID,
|
|
1959
|
-
NCERT_PAYLOAD,
|
|
1960
|
-
NCERT_SIG,
|
|
1961
|
-
PROOF_NONE,
|
|
1962
|
-
PROOF_CAPSULE,
|
|
1963
|
-
PROOF_JWT,
|
|
1964
|
-
PROOF_MTLS,
|
|
1965
|
-
PROOF_LOOM,
|
|
1966
|
-
PROOF_WITNESS,
|
|
1967
|
-
ProofType,
|
|
1968
|
-
BodyProfile,
|
|
1969
|
-
ERR_INVALID_PACKET,
|
|
1970
|
-
ERR_BAD_SIGNATURE,
|
|
1971
|
-
ERR_REPLAY_DETECTED,
|
|
1972
|
-
ERR_CONTRACT_VIOLATION
|
|
1973
|
-
} from "@nextera.one/axis-protocol";
|
|
1974
|
-
var init_constants = __esm({
|
|
1975
|
-
"src/core/constants.ts"() {
|
|
1976
|
-
}
|
|
1977
|
-
});
|
|
1978
|
-
|
|
1979
3325
|
// src/engine/observation/response-observer.ts
|
|
1980
3326
|
function verifyResponse(ctx, response) {
|
|
1981
3327
|
if (!response.effect || typeof response.effect !== "string") {
|
|
@@ -3494,37 +4840,6 @@ var init_packet = __esm({
|
|
|
3494
4840
|
}
|
|
3495
4841
|
});
|
|
3496
4842
|
|
|
3497
|
-
// src/security/scopes.ts
|
|
3498
|
-
function hasScope(scopes, required) {
|
|
3499
|
-
if (!Array.isArray(scopes) || scopes.length === 0) {
|
|
3500
|
-
return false;
|
|
3501
|
-
}
|
|
3502
|
-
if (scopes.includes(required)) {
|
|
3503
|
-
return true;
|
|
3504
|
-
}
|
|
3505
|
-
const [resource, id] = required.split(":");
|
|
3506
|
-
if (resource && id) {
|
|
3507
|
-
const wildcard = `${resource}:*`;
|
|
3508
|
-
if (scopes.includes(wildcard)) {
|
|
3509
|
-
return true;
|
|
3510
|
-
}
|
|
3511
|
-
}
|
|
3512
|
-
return false;
|
|
3513
|
-
}
|
|
3514
|
-
function parseScope(scope) {
|
|
3515
|
-
const parts = scope.split(":");
|
|
3516
|
-
if (parts.length !== 2) return null;
|
|
3517
|
-
return { resource: parts[0], id: parts[1] };
|
|
3518
|
-
}
|
|
3519
|
-
function canAccessResource(scopes, resourceType, resourceId) {
|
|
3520
|
-
const required = `${resourceType}:${resourceId}`;
|
|
3521
|
-
return hasScope(scopes, required);
|
|
3522
|
-
}
|
|
3523
|
-
var init_scopes = __esm({
|
|
3524
|
-
"src/security/scopes.ts"() {
|
|
3525
|
-
}
|
|
3526
|
-
});
|
|
3527
|
-
|
|
3528
4843
|
// src/security/capabilities.ts
|
|
3529
4844
|
var CAPABILITIES, PROOF_CAPABILITIES, INTENT_REQUIREMENTS;
|
|
3530
4845
|
var init_capabilities = __esm({
|
|
@@ -4209,23 +5524,62 @@ var require_axis_request_decorator = __commonJS({
|
|
|
4209
5524
|
}
|
|
4210
5525
|
});
|
|
4211
5526
|
|
|
4212
|
-
// src/
|
|
4213
|
-
var
|
|
4214
|
-
|
|
4215
|
-
|
|
4216
|
-
|
|
4217
|
-
var
|
|
4218
|
-
|
|
4219
|
-
|
|
4220
|
-
|
|
4221
|
-
|
|
4222
|
-
|
|
4223
|
-
|
|
4224
|
-
|
|
4225
|
-
|
|
4226
|
-
|
|
5527
|
+
// src/engine/observer-discovery.service.ts
|
|
5528
|
+
var require_observer_discovery_service = __commonJS({
|
|
5529
|
+
"src/engine/observer-discovery.service.ts"(exports) {
|
|
5530
|
+
"use strict";
|
|
5531
|
+
var __decorate = exports && exports.__decorate || function(decorators, target, key, desc) {
|
|
5532
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
5533
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5534
|
+
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;
|
|
5535
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
5536
|
+
};
|
|
5537
|
+
var __metadata = exports && exports.__metadata || function(k, v) {
|
|
5538
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
5539
|
+
};
|
|
5540
|
+
var ObserverDiscoveryService_1;
|
|
5541
|
+
var _a;
|
|
5542
|
+
var _b;
|
|
5543
|
+
var _c;
|
|
5544
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5545
|
+
exports.ObserverDiscoveryService = void 0;
|
|
5546
|
+
var common_1 = __require("@nestjs/common");
|
|
5547
|
+
var core_1 = __require("@nestjs/core");
|
|
5548
|
+
var observer_decorator_1 = (init_observer_decorator(), __toCommonJS(observer_decorator_exports));
|
|
5549
|
+
var observer_registry_1 = require_observer_registry();
|
|
5550
|
+
var ObserverDiscoveryService2 = ObserverDiscoveryService_1 = class ObserverDiscoveryService {
|
|
5551
|
+
constructor(discovery, reflector, registry) {
|
|
5552
|
+
this.discovery = discovery;
|
|
5553
|
+
this.reflector = reflector;
|
|
5554
|
+
this.registry = registry;
|
|
5555
|
+
this.logger = new common_1.Logger(ObserverDiscoveryService_1.name);
|
|
5556
|
+
}
|
|
5557
|
+
onApplicationBootstrap() {
|
|
5558
|
+
const providers = this.discovery.getProviders();
|
|
5559
|
+
let count = 0;
|
|
5560
|
+
for (const wrapper of providers) {
|
|
5561
|
+
const { instance } = wrapper;
|
|
5562
|
+
if (!instance || !instance.constructor)
|
|
5563
|
+
continue;
|
|
5564
|
+
const meta = this.reflector.get(observer_decorator_1.OBSERVER_METADATA_KEY, instance.constructor);
|
|
5565
|
+
if (!meta)
|
|
5566
|
+
continue;
|
|
5567
|
+
const observer = instance;
|
|
5568
|
+
if (typeof observer.observe !== "function") {
|
|
5569
|
+
this.logger.warn(`@Observer on ${instance.constructor.name} is missing observe() and was skipped`);
|
|
5570
|
+
continue;
|
|
5571
|
+
}
|
|
5572
|
+
this.registry.register(observer, meta);
|
|
5573
|
+
count++;
|
|
5574
|
+
}
|
|
5575
|
+
this.logger.log(`Auto-registered ${count} observers via @Observer()`);
|
|
4227
5576
|
}
|
|
4228
5577
|
};
|
|
5578
|
+
exports.ObserverDiscoveryService = ObserverDiscoveryService2;
|
|
5579
|
+
exports.ObserverDiscoveryService = ObserverDiscoveryService2 = ObserverDiscoveryService_1 = __decorate([
|
|
5580
|
+
(0, common_1.Injectable)(),
|
|
5581
|
+
__metadata("design:paramtypes", [typeof (_a = typeof core_1.DiscoveryService !== "undefined" && core_1.DiscoveryService) === "function" ? _a : Object, typeof (_b = typeof core_1.Reflector !== "undefined" && core_1.Reflector) === "function" ? _b : Object, typeof (_c = typeof observer_registry_1.ObserverRegistry !== "undefined" && observer_registry_1.ObserverRegistry) === "function" ? _c : Object])
|
|
5582
|
+
], ObserverDiscoveryService2);
|
|
4229
5583
|
}
|
|
4230
5584
|
});
|
|
4231
5585
|
|
|
@@ -4250,6 +5604,7 @@ var require_handler_discovery_service = __commonJS({
|
|
|
4250
5604
|
exports.HandlerDiscoveryService = void 0;
|
|
4251
5605
|
var common_1 = __require("@nestjs/common");
|
|
4252
5606
|
var core_1 = __require("@nestjs/core");
|
|
5607
|
+
var observer_decorator_1 = (init_observer_decorator(), __toCommonJS(observer_decorator_exports));
|
|
4253
5608
|
var handler_sensors_decorator_1 = (init_handler_sensors_decorator(), __toCommonJS(handler_sensors_decorator_exports));
|
|
4254
5609
|
var handler_decorator_1 = (init_handler_decorator(), __toCommonJS(handler_decorator_exports));
|
|
4255
5610
|
var intent_decorator_1 = (init_intent_decorator(), __toCommonJS(intent_decorator_exports));
|
|
@@ -4272,20 +5627,36 @@ var require_handler_discovery_service = __commonJS({
|
|
|
4272
5627
|
if (!handlerMeta)
|
|
4273
5628
|
continue;
|
|
4274
5629
|
const handlerName = handlerMeta.intent || metatype.name;
|
|
5630
|
+
const prefix = handlerMeta.intent || metatype.name;
|
|
4275
5631
|
const proto = Object.getPrototypeOf(instance);
|
|
4276
5632
|
const methods = this.scanner.getAllMethodNames(proto);
|
|
5633
|
+
const routes = Reflect.getMetadata(intent_decorator_1.INTENT_ROUTES_KEY, metatype) || [];
|
|
5634
|
+
const routedMethods = new Set(routes.map((route) => String(route.methodName)));
|
|
4277
5635
|
let registered = 0;
|
|
4278
5636
|
const handlerSensors = Reflect.getMetadata(handler_sensors_decorator_1.HANDLER_SENSORS_KEY, metatype) || [];
|
|
5637
|
+
const handlerObservers = Reflect.getMetadata(observer_decorator_1.OBSERVER_BINDINGS_KEY, metatype) || [];
|
|
5638
|
+
for (const route of routes) {
|
|
5639
|
+
const intentName = route.absolute ? route.action : `${prefix}.${route.action}`;
|
|
5640
|
+
if (!this.router.has(intentName)) {
|
|
5641
|
+
this.router.register(intentName, instance[route.methodName].bind(instance));
|
|
5642
|
+
registered++;
|
|
5643
|
+
totalIntents++;
|
|
5644
|
+
}
|
|
5645
|
+
this.router.registerIntentMeta(intentName, proto, String(route.methodName), handlerSensors, handlerObservers);
|
|
5646
|
+
}
|
|
4279
5647
|
for (const methodName of methods) {
|
|
5648
|
+
if (routedMethods.has(methodName))
|
|
5649
|
+
continue;
|
|
4280
5650
|
const meta = Reflect.getMetadata(intent_decorator_1.INTENT_METADATA_KEY, proto, methodName);
|
|
4281
5651
|
if (!meta?.intent)
|
|
4282
5652
|
continue;
|
|
4283
|
-
|
|
4284
|
-
|
|
5653
|
+
const intentName = meta.absolute ? meta.intent : `${prefix}.${meta.intent}`;
|
|
5654
|
+
if (!this.router.has(intentName)) {
|
|
5655
|
+
this.router.register(intentName, instance[methodName].bind(instance));
|
|
4285
5656
|
registered++;
|
|
4286
5657
|
totalIntents++;
|
|
4287
5658
|
}
|
|
4288
|
-
this.router.registerIntentMeta(
|
|
5659
|
+
this.router.registerIntentMeta(intentName, proto, methodName, handlerSensors, handlerObservers);
|
|
4289
5660
|
}
|
|
4290
5661
|
if (registered > 0) {
|
|
4291
5662
|
this.logger.log(`Auto-registered ${registered} intents from ${handlerName}`);
|
|
@@ -5854,6 +7225,10 @@ var init_crypto = __esm({
|
|
|
5854
7225
|
// src/decorators/index.ts
|
|
5855
7226
|
var decorators_exports = {};
|
|
5856
7227
|
__export(decorators_exports, {
|
|
7228
|
+
CAPSULE_POLICY_METADATA_KEY: () => CAPSULE_POLICY_METADATA_KEY,
|
|
7229
|
+
CHAIN_METADATA_KEY: () => CHAIN_METADATA_KEY,
|
|
7230
|
+
CapsulePolicy: () => CapsulePolicy,
|
|
7231
|
+
Chain: () => Chain,
|
|
5857
7232
|
HANDLER_METADATA_KEY: () => HANDLER_METADATA_KEY,
|
|
5858
7233
|
Handler: () => Handler,
|
|
5859
7234
|
INTENT_BODY_KEY: () => INTENT_BODY_KEY,
|
|
@@ -5863,6 +7238,9 @@ __export(decorators_exports, {
|
|
|
5863
7238
|
Intent: () => Intent,
|
|
5864
7239
|
IntentBody: () => IntentBody,
|
|
5865
7240
|
IntentSensors: () => IntentSensors,
|
|
7241
|
+
OBSERVER_BINDINGS_KEY: () => OBSERVER_BINDINGS_KEY,
|
|
7242
|
+
OBSERVER_METADATA_KEY: () => OBSERVER_METADATA_KEY,
|
|
7243
|
+
Observer: () => Observer,
|
|
5866
7244
|
SENSOR_METADATA_KEY: () => SENSOR_METADATA_KEY,
|
|
5867
7245
|
Sensor: () => Sensor,
|
|
5868
7246
|
TLV_FIELDS_KEY: () => TLV_FIELDS_KEY,
|
|
@@ -5872,16 +7250,21 @@ __export(decorators_exports, {
|
|
|
5872
7250
|
TlvMinLen: () => TlvMinLen,
|
|
5873
7251
|
TlvRange: () => TlvRange,
|
|
5874
7252
|
TlvUtf8Pattern: () => TlvUtf8Pattern,
|
|
5875
|
-
TlvValidate: () => TlvValidate
|
|
7253
|
+
TlvValidate: () => TlvValidate,
|
|
7254
|
+
mergeCapsulePolicyOptions: () => mergeCapsulePolicyOptions,
|
|
7255
|
+
normalizeCapsulePolicyOptions: () => normalizeCapsulePolicyOptions
|
|
5876
7256
|
});
|
|
5877
7257
|
var init_decorators = __esm({
|
|
5878
7258
|
"src/decorators/index.ts"() {
|
|
5879
7259
|
__reExport(decorators_exports, __toESM(require_axis_request_decorator()));
|
|
7260
|
+
init_capsule_policy_decorator();
|
|
7261
|
+
init_chain_decorator();
|
|
5880
7262
|
__reExport(decorators_exports, __toESM(require_dto_schema_util()));
|
|
5881
7263
|
init_handler_decorator();
|
|
5882
7264
|
init_intent_body_decorator();
|
|
5883
7265
|
init_intent_sensors_decorator();
|
|
5884
7266
|
init_intent_decorator();
|
|
7267
|
+
init_observer_decorator();
|
|
5885
7268
|
init_sensor_decorator();
|
|
5886
7269
|
init_tlv_field_decorator();
|
|
5887
7270
|
}
|
|
@@ -5893,6 +7276,18 @@ var init_axis_decoded = __esm({
|
|
|
5893
7276
|
}
|
|
5894
7277
|
});
|
|
5895
7278
|
|
|
7279
|
+
// src/engine/axis-chain.types.ts
|
|
7280
|
+
var init_axis_chain_types = __esm({
|
|
7281
|
+
"src/engine/axis-chain.types.ts"() {
|
|
7282
|
+
}
|
|
7283
|
+
});
|
|
7284
|
+
|
|
7285
|
+
// src/engine/axis-observer.interface.ts
|
|
7286
|
+
var init_axis_observer_interface = __esm({
|
|
7287
|
+
"src/engine/axis-observer.interface.ts"() {
|
|
7288
|
+
}
|
|
7289
|
+
});
|
|
7290
|
+
|
|
5896
7291
|
// src/engine/observation/observation-queue.types.ts
|
|
5897
7292
|
var init_observation_queue_types = __esm({
|
|
5898
7293
|
"src/engine/observation/observation-queue.types.ts"() {
|
|
@@ -5927,6 +7322,7 @@ var init_observation = __esm({
|
|
|
5927
7322
|
// src/engine/index.ts
|
|
5928
7323
|
var engine_exports = {};
|
|
5929
7324
|
__export(engine_exports, {
|
|
7325
|
+
AXIS_EXECUTION_CONTEXT_KEY: () => AXIS_EXECUTION_CONTEXT_KEY,
|
|
5930
7326
|
BAND: () => BAND,
|
|
5931
7327
|
PRE_DECODE_BOUNDARY: () => PRE_DECODE_BOUNDARY,
|
|
5932
7328
|
ResponseObserver: () => ResponseObserver,
|
|
@@ -5938,24 +7334,34 @@ __export(engine_exports, {
|
|
|
5938
7334
|
encodeQueueMessage: () => encodeQueueMessage,
|
|
5939
7335
|
endStage: () => endStage,
|
|
5940
7336
|
finalizeObservation: () => finalizeObservation,
|
|
7337
|
+
getAxisExecutionContext: () => getAxisExecutionContext,
|
|
5941
7338
|
hashObservation: () => hashObservation,
|
|
7339
|
+
mergeAxisExecutionContext: () => mergeAxisExecutionContext,
|
|
5942
7340
|
observation: () => observation_exports,
|
|
5943
7341
|
parseAutoClaimEntries: () => parseAutoClaimEntries,
|
|
5944
7342
|
parseStreamEntries: () => parseStreamEntries,
|
|
5945
7343
|
recordSensor: () => recordSensor,
|
|
5946
7344
|
stableJsonStringify: () => stableJsonStringify,
|
|
5947
7345
|
startStage: () => startStage,
|
|
5948
|
-
verifyResponse: () => verifyResponse
|
|
7346
|
+
verifyResponse: () => verifyResponse,
|
|
7347
|
+
withAxisExecutionContext: () => withAxisExecutionContext
|
|
5949
7348
|
});
|
|
5950
7349
|
var init_engine = __esm({
|
|
5951
7350
|
"src/engine/index.ts"() {
|
|
5952
7351
|
init_axis_decoded();
|
|
7352
|
+
__reExport(engine_exports, __toESM(require_axis_chain_executor()));
|
|
7353
|
+
init_axis_chain_types();
|
|
7354
|
+
init_axis_execution_context();
|
|
5953
7355
|
init_axis_observation();
|
|
7356
|
+
init_axis_observer_interface();
|
|
5954
7357
|
__reExport(engine_exports, __toESM(require_handler_discovery_service()));
|
|
5955
7358
|
__reExport(engine_exports, __toESM(require_intent_router()));
|
|
5956
7359
|
init_observation();
|
|
7360
|
+
__reExport(engine_exports, __toESM(require_observer_discovery_service()));
|
|
7361
|
+
__reExport(engine_exports, __toESM(require_observer_dispatcher_service()));
|
|
5957
7362
|
init_sensor_bands();
|
|
5958
7363
|
__reExport(engine_exports, __toESM(require_sensor_discovery_service()));
|
|
7364
|
+
__reExport(engine_exports, __toESM(require_observer_registry()));
|
|
5959
7365
|
__reExport(engine_exports, __toESM(require_sensor_registry()));
|
|
5960
7366
|
init_observation();
|
|
5961
7367
|
}
|
|
@@ -7993,6 +9399,7 @@ var index_exports = {};
|
|
|
7993
9399
|
__export(index_exports, {
|
|
7994
9400
|
ATS1_HDR: () => ATS1_HDR,
|
|
7995
9401
|
ATS1_SCHEMA: () => ATS1_SCHEMA,
|
|
9402
|
+
AXIS_EXECUTION_CONTEXT_KEY: () => AXIS_EXECUTION_CONTEXT_KEY,
|
|
7996
9403
|
AXIS_MAGIC: () => AXIS_MAGIC,
|
|
7997
9404
|
AXIS_OPCODES: () => AXIS_OPCODES,
|
|
7998
9405
|
AXIS_UPLOAD_FILE_STORE: () => AXIS_UPLOAD_FILE_STORE,
|
|
@@ -8000,6 +9407,7 @@ __export(index_exports, {
|
|
|
8000
9407
|
AXIS_UPLOAD_SESSION_STORE: () => AXIS_UPLOAD_SESSION_STORE,
|
|
8001
9408
|
AXIS_VERSION: () => AXIS_VERSION,
|
|
8002
9409
|
Ats1Codec: () => ats1_exports,
|
|
9410
|
+
AxisChainExecutor: () => import_axis_chain.AxisChainExecutor,
|
|
8003
9411
|
AxisContext: () => import_axis_request.AxisContext,
|
|
8004
9412
|
AxisDemoPubkey: () => import_axis_request.AxisDemoPubkey,
|
|
8005
9413
|
AxisEffect: () => import_intent2.AxisEffect,
|
|
@@ -8018,9 +9426,13 @@ __export(index_exports, {
|
|
|
8018
9426
|
BAND: () => BAND,
|
|
8019
9427
|
BodyProfile: () => BodyProfile,
|
|
8020
9428
|
CAPABILITIES: () => CAPABILITIES,
|
|
9429
|
+
CAPSULE_POLICY_METADATA_KEY: () => CAPSULE_POLICY_METADATA_KEY,
|
|
8021
9430
|
CCE_ERROR: () => CCE_ERROR,
|
|
8022
9431
|
CCE_PROTOCOL_VERSION: () => CCE_PROTOCOL_VERSION,
|
|
9432
|
+
CHAIN_METADATA_KEY: () => CHAIN_METADATA_KEY,
|
|
9433
|
+
CapsulePolicy: () => CapsulePolicy,
|
|
8023
9434
|
CceError: () => CceError,
|
|
9435
|
+
Chain: () => Chain,
|
|
8024
9436
|
ContractViolationError: () => ContractViolationError,
|
|
8025
9437
|
DEFAULT_CONTRACTS: () => DEFAULT_CONTRACTS,
|
|
8026
9438
|
DEFAULT_TIMEOUT: () => DEFAULT_TIMEOUT,
|
|
@@ -8066,6 +9478,12 @@ __export(index_exports, {
|
|
|
8066
9478
|
NCERT_PUB: () => NCERT_PUB,
|
|
8067
9479
|
NCERT_SCOPE: () => NCERT_SCOPE,
|
|
8068
9480
|
NCERT_SIG: () => NCERT_SIG,
|
|
9481
|
+
OBSERVER_BINDINGS_KEY: () => OBSERVER_BINDINGS_KEY,
|
|
9482
|
+
OBSERVER_METADATA_KEY: () => OBSERVER_METADATA_KEY,
|
|
9483
|
+
Observer: () => Observer,
|
|
9484
|
+
ObserverDiscoveryService: () => import_observer_discovery.ObserverDiscoveryService,
|
|
9485
|
+
ObserverDispatcherService: () => import_observer_dispatcher.ObserverDispatcherService,
|
|
9486
|
+
ObserverRegistry: () => import_observer2.ObserverRegistry,
|
|
8069
9487
|
PRE_DECODE_BOUNDARY: () => PRE_DECODE_BOUNDARY,
|
|
8070
9488
|
PROOF_CAPABILITIES: () => PROOF_CAPABILITIES,
|
|
8071
9489
|
PROOF_CAPSULE: () => PROOF_CAPSULE,
|
|
@@ -8183,6 +9601,7 @@ __export(index_exports, {
|
|
|
8183
9601
|
extractDtoSchema: () => import_dto_schema.extractDtoSchema,
|
|
8184
9602
|
finalizeObservation: () => finalizeObservation,
|
|
8185
9603
|
generateEd25519KeyPair: () => generateEd25519KeyPair,
|
|
9604
|
+
getAxisExecutionContext: () => getAxisExecutionContext,
|
|
8186
9605
|
getSignTarget: () => getSignTarget,
|
|
8187
9606
|
hasScope: () => hasScope,
|
|
8188
9607
|
hashObservation: () => hashObservation,
|
|
@@ -8190,6 +9609,7 @@ __export(index_exports, {
|
|
|
8190
9609
|
isKnownOpcode: () => isKnownOpcode,
|
|
8191
9610
|
isTimestampValid: () => isTimestampValid,
|
|
8192
9611
|
loom: () => loom_exports,
|
|
9612
|
+
mergeAxisExecutionContext: () => mergeAxisExecutionContext,
|
|
8193
9613
|
nonce16: () => nonce16,
|
|
8194
9614
|
normalizeSensorDecision: () => normalizeSensorDecision,
|
|
8195
9615
|
packPasskeyLoginOptionsReq: () => packPasskeyLoginOptionsReq,
|
|
@@ -8221,15 +9641,19 @@ __export(index_exports, {
|
|
|
8221
9641
|
varintLength: () => varintLength,
|
|
8222
9642
|
varintU: () => varintU,
|
|
8223
9643
|
verifyFrameSignature: () => verifyFrameSignature,
|
|
8224
|
-
verifyResponse: () => verifyResponse
|
|
9644
|
+
verifyResponse: () => verifyResponse,
|
|
9645
|
+
withAxisExecutionContext: () => withAxisExecutionContext
|
|
8225
9646
|
});
|
|
8226
|
-
var import_dto_schema, import_axis_id, import_axis_response, import_intent2, import_axis_files, import_axis_request, import_handler_discovery, import_sensor_discovery, import_sensor2, import_axis_sensor_chain;
|
|
9647
|
+
var import_dto_schema, import_axis_id, import_axis_response, import_axis_chain, import_intent2, import_axis_files, import_axis_request, import_observer_discovery, import_observer_dispatcher, import_handler_discovery, import_sensor_discovery, import_observer2, import_sensor2, import_axis_sensor_chain;
|
|
8227
9648
|
var init_index = __esm({
|
|
8228
9649
|
"src/index.ts"() {
|
|
9650
|
+
init_chain_decorator();
|
|
9651
|
+
init_capsule_policy_decorator();
|
|
8229
9652
|
init_handler_decorator();
|
|
8230
9653
|
init_intent_decorator();
|
|
8231
9654
|
init_intent_body_decorator();
|
|
8232
9655
|
init_intent_sensors_decorator();
|
|
9656
|
+
init_observer_decorator();
|
|
8233
9657
|
init_handler_sensors_decorator();
|
|
8234
9658
|
init_sensor_decorator();
|
|
8235
9659
|
init_tlv_field_decorator();
|
|
@@ -8238,6 +9662,8 @@ var init_index = __esm({
|
|
|
8238
9662
|
import_axis_id = __toESM(require_axis_id_dto());
|
|
8239
9663
|
init_axis_partial_type();
|
|
8240
9664
|
import_axis_response = __toESM(require_axis_response_dto());
|
|
9665
|
+
import_axis_chain = __toESM(require_axis_chain_executor());
|
|
9666
|
+
init_axis_execution_context();
|
|
8241
9667
|
import_intent2 = __toESM(require_intent_router());
|
|
8242
9668
|
init_sensor_bands();
|
|
8243
9669
|
init_stable_json();
|
|
@@ -8275,8 +9701,11 @@ var init_index = __esm({
|
|
|
8275
9701
|
init_disk_upload_file_store();
|
|
8276
9702
|
import_axis_request = __toESM(require_axis_request_decorator());
|
|
8277
9703
|
init_axis_error();
|
|
9704
|
+
import_observer_discovery = __toESM(require_observer_discovery_service());
|
|
9705
|
+
import_observer_dispatcher = __toESM(require_observer_dispatcher_service());
|
|
8278
9706
|
import_handler_discovery = __toESM(require_handler_discovery_service());
|
|
8279
9707
|
import_sensor_discovery = __toESM(require_sensor_discovery_service());
|
|
9708
|
+
import_observer2 = __toESM(require_observer_registry());
|
|
8280
9709
|
import_sensor2 = __toESM(require_sensor_registry());
|
|
8281
9710
|
init_axis_observation();
|
|
8282
9711
|
import_axis_sensor_chain = __toESM(require_axis_sensor_chain_service());
|
|
@@ -8297,6 +9726,7 @@ var init_index = __esm({
|
|
|
8297
9726
|
}
|
|
8298
9727
|
});
|
|
8299
9728
|
init_index();
|
|
9729
|
+
var export_AxisChainExecutor = import_axis_chain.AxisChainExecutor;
|
|
8300
9730
|
var export_AxisContext = import_axis_request.AxisContext;
|
|
8301
9731
|
var export_AxisDemoPubkey = import_axis_request.AxisDemoPubkey;
|
|
8302
9732
|
var export_AxisEffect = import_intent2.AxisEffect;
|
|
@@ -8309,6 +9739,9 @@ var export_AxisResponseDto = import_axis_response.AxisResponseDto;
|
|
|
8309
9739
|
var export_AxisSensorChainService = import_axis_sensor_chain.AxisSensorChainService;
|
|
8310
9740
|
var export_HandlerDiscoveryService = import_handler_discovery.HandlerDiscoveryService;
|
|
8311
9741
|
var export_IntentRouter = import_intent2.IntentRouter;
|
|
9742
|
+
var export_ObserverDiscoveryService = import_observer_discovery.ObserverDiscoveryService;
|
|
9743
|
+
var export_ObserverDispatcherService = import_observer_dispatcher.ObserverDispatcherService;
|
|
9744
|
+
var export_ObserverRegistry = import_observer2.ObserverRegistry;
|
|
8312
9745
|
var export_RESPONSE_TAG_CREATED_AT = import_axis_response.RESPONSE_TAG_CREATED_AT;
|
|
8313
9746
|
var export_RESPONSE_TAG_CREATED_BY = import_axis_response.RESPONSE_TAG_CREATED_BY;
|
|
8314
9747
|
var export_RESPONSE_TAG_ID = import_axis_response.RESPONSE_TAG_ID;
|
|
@@ -8321,6 +9754,7 @@ var export_extractDtoSchema = import_dto_schema.extractDtoSchema;
|
|
|
8321
9754
|
export {
|
|
8322
9755
|
ATS1_HDR,
|
|
8323
9756
|
ATS1_SCHEMA,
|
|
9757
|
+
AXIS_EXECUTION_CONTEXT_KEY,
|
|
8324
9758
|
AXIS_MAGIC,
|
|
8325
9759
|
AXIS_OPCODES,
|
|
8326
9760
|
AXIS_UPLOAD_FILE_STORE,
|
|
@@ -8328,6 +9762,7 @@ export {
|
|
|
8328
9762
|
AXIS_UPLOAD_SESSION_STORE,
|
|
8329
9763
|
AXIS_VERSION,
|
|
8330
9764
|
ats1_exports as Ats1Codec,
|
|
9765
|
+
export_AxisChainExecutor as AxisChainExecutor,
|
|
8331
9766
|
export_AxisContext as AxisContext,
|
|
8332
9767
|
export_AxisDemoPubkey as AxisDemoPubkey,
|
|
8333
9768
|
export_AxisEffect as AxisEffect,
|
|
@@ -8346,9 +9781,13 @@ export {
|
|
|
8346
9781
|
BAND,
|
|
8347
9782
|
BodyProfile,
|
|
8348
9783
|
CAPABILITIES,
|
|
9784
|
+
CAPSULE_POLICY_METADATA_KEY,
|
|
8349
9785
|
CCE_ERROR,
|
|
8350
9786
|
CCE_PROTOCOL_VERSION,
|
|
9787
|
+
CHAIN_METADATA_KEY,
|
|
9788
|
+
CapsulePolicy,
|
|
8351
9789
|
CceError,
|
|
9790
|
+
Chain,
|
|
8352
9791
|
ContractViolationError,
|
|
8353
9792
|
DEFAULT_CONTRACTS,
|
|
8354
9793
|
DEFAULT_TIMEOUT,
|
|
@@ -8394,6 +9833,12 @@ export {
|
|
|
8394
9833
|
NCERT_PUB,
|
|
8395
9834
|
NCERT_SCOPE,
|
|
8396
9835
|
NCERT_SIG,
|
|
9836
|
+
OBSERVER_BINDINGS_KEY,
|
|
9837
|
+
OBSERVER_METADATA_KEY,
|
|
9838
|
+
Observer,
|
|
9839
|
+
export_ObserverDiscoveryService as ObserverDiscoveryService,
|
|
9840
|
+
export_ObserverDispatcherService as ObserverDispatcherService,
|
|
9841
|
+
export_ObserverRegistry as ObserverRegistry,
|
|
8397
9842
|
PRE_DECODE_BOUNDARY,
|
|
8398
9843
|
PROOF_CAPABILITIES,
|
|
8399
9844
|
PROOF_CAPSULE,
|
|
@@ -8511,6 +9956,7 @@ export {
|
|
|
8511
9956
|
export_extractDtoSchema as extractDtoSchema,
|
|
8512
9957
|
finalizeObservation,
|
|
8513
9958
|
generateEd25519KeyPair,
|
|
9959
|
+
getAxisExecutionContext,
|
|
8514
9960
|
getSignTarget,
|
|
8515
9961
|
hasScope,
|
|
8516
9962
|
hashObservation,
|
|
@@ -8518,6 +9964,7 @@ export {
|
|
|
8518
9964
|
isKnownOpcode,
|
|
8519
9965
|
isTimestampValid,
|
|
8520
9966
|
loom_exports as loom,
|
|
9967
|
+
mergeAxisExecutionContext,
|
|
8521
9968
|
nonce16,
|
|
8522
9969
|
normalizeSensorDecision,
|
|
8523
9970
|
packPasskeyLoginOptionsReq,
|
|
@@ -8549,6 +9996,7 @@ export {
|
|
|
8549
9996
|
varintLength,
|
|
8550
9997
|
varintU,
|
|
8551
9998
|
verifyFrameSignature,
|
|
8552
|
-
verifyResponse
|
|
9999
|
+
verifyResponse,
|
|
10000
|
+
withAxisExecutionContext
|
|
8553
10001
|
};
|
|
8554
10002
|
//# sourceMappingURL=index.mjs.map
|