@nextera.one/axis-server-sdk 0.1.1 → 0.3.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/dist/index.d.ts CHANGED
@@ -1,4 +1,7 @@
1
+ import { AxisFrame } from './core/index.js';
2
+ export { AXIS_MAGIC, AXIS_VERSION, AxisFrameZ, TLV as AxisTlvType, ERR_BAD_SIGNATURE, ERR_CONTRACT_VIOLATION, ERR_INVALID_PACKET, ERR_REPLAY_DETECTED, FLAG_BODY_TLV, FLAG_CHAIN_REQ, FLAG_HAS_WITNESS, MAX_BODY_LEN, MAX_FRAME_LEN, MAX_HDR_LEN, MAX_SIG_LEN, PROOF_CAPSULE, PROOF_JWT, PROOF_LOOM, PROOF_MTLS, TLV, TLV_ACTOR_ID, TLV_AUD, TLV_EFFECT, TLV_ERROR_CODE, TLV_ERROR_MSG, TLV_INTENT, TLV_KID, TLV_LOOM_PRESENCE_ID, TLV_LOOM_THREAD_HASH, TLV_LOOM_WRIT, TLV_NODE, TLV_NODE_CERT_HASH, TLV_NODE_KID, TLV_NONCE, TLV_OK, TLV_PID, TLV_PREV_HASH, TLV_PROOF_REF, TLV_PROOF_TYPE, TLV_RECEIPT_HASH, TLV_RID, TLV_TRACE_ID, TLV_TS, computeReceiptHash, computeSignaturePayload, decodeArray, decodeFrame, decodeObject, decodeTLVs, decodeTLVsList, decodeVarint, encodeFrame, encodeTLVs, encodeVarint, generateEd25519KeyPair, getSignTarget, sha256, signFrame, varintLength, verifyFrameSignature } from './core/index.js';
1
3
  import { OnModuleInit } from '@nestjs/common';
4
+ import 'zod';
2
5
 
3
6
  declare const HANDLER_METADATA_KEY = "axis:handler";
4
7
  declare function Handler(intent?: string): ClassDecorator;
@@ -16,14 +19,6 @@ interface IntentOptions {
16
19
  }
17
20
  declare function Intent(action: string, options?: IntentOptions): MethodDecorator;
18
21
 
19
- interface AxisFrame {
20
- flags: number;
21
- headers: Map<number, Uint8Array>;
22
- body: Uint8Array;
23
- sig: Uint8Array;
24
- metadata?: Record<string, any>;
25
- }
26
-
27
22
  interface AxisEffect {
28
23
  ok: boolean;
29
24
  effect: string;
@@ -39,6 +34,638 @@ declare class IntentRouter {
39
34
  private recordLatency;
40
35
  }
41
36
 
37
+ declare const ATS1_HDR: {
38
+ readonly INTENT_ID: 1;
39
+ readonly ACTOR_KEY_ID: 2;
40
+ readonly CAPSULE_ID: 3;
41
+ readonly NONCE: 4;
42
+ readonly TS_MS: 5;
43
+ readonly SCHEMA_ID: 6;
44
+ readonly BODY_HASH: 7;
45
+ readonly TRACE_ID: 8;
46
+ };
47
+ declare const ATS1_SCHEMA: {
48
+ readonly PASSKEY_LOGIN_OPTIONS_REQ: 2001;
49
+ readonly PASSKEY_LOGIN_OPTIONS_RES: 2002;
50
+ readonly PASSKEY_LOGIN_VERIFY_REQ: 2011;
51
+ readonly PASSKEY_LOGIN_VERIFY_RES: 2012;
52
+ readonly PASSKEY_REGISTER_OPTIONS_REQ: 2021;
53
+ readonly PASSKEY_REGISTER_OPTIONS_RES: 2022;
54
+ readonly PASSKEY_REGISTER_VERIFY_REQ: 2031;
55
+ readonly PASSKEY_REGISTER_VERIFY_RES: 2032;
56
+ };
57
+
58
+ type Ats1FieldType = 'bytes' | 'utf8' | 'uvarint' | 'u64be' | 'nested';
59
+ type Ats1FieldDescriptor = {
60
+ tag: number;
61
+ name: string;
62
+ type: Ats1FieldType;
63
+ required?: boolean;
64
+ repeated?: boolean;
65
+ nestedSchema?: Ats1SchemaDescriptor;
66
+ maxLen?: number;
67
+ };
68
+ type Ats1SchemaDescriptor = {
69
+ schemaId: number;
70
+ name: string;
71
+ strict: boolean;
72
+ maxNestingDepth: number;
73
+ maxBodyBytes?: number;
74
+ fields: Ats1FieldDescriptor[];
75
+ };
76
+ type DecodedTlv = {
77
+ tag: number;
78
+ value: Buffer;
79
+ };
80
+ type DecodedTlvMap = Map<number, Buffer[]>;
81
+ type SensorInputLike = {
82
+ hdrTLVs: DecodedTlvMap;
83
+ bodyTLVs: DecodedTlvMap;
84
+ schemaId: number;
85
+ intentId: number;
86
+ };
87
+ type Ats1Limits = {
88
+ maxVarintBytes: number;
89
+ maxTlvCount: number;
90
+ maxValueBytes: number;
91
+ maxNestingDepth: number;
92
+ };
93
+ declare const DEFAULT_LIMITS: Ats1Limits;
94
+ declare function encodeUVarint(n: number | bigint): Buffer;
95
+ declare function decodeUVarint(buf: Buffer, offset: number, limits?: Ats1Limits): {
96
+ value: bigint;
97
+ offset: number;
98
+ bytesRead: number;
99
+ };
100
+ declare function encodeU64BE(n: bigint): Buffer;
101
+ declare function decodeU64BE(buf: Buffer): bigint;
102
+ declare function sha256(data: Buffer): Buffer;
103
+ declare function encodeTLV(tag: number, value: Buffer): Buffer;
104
+ declare function encodeTLVStreamCanonical(entries: DecodedTlv[]): Buffer;
105
+ declare function decodeTLVStream(stream: Buffer, limits?: Ats1Limits): DecodedTlv[];
106
+ declare function tlvsToMap(entries: DecodedTlv[]): DecodedTlvMap;
107
+ type LogicalBody = {
108
+ schemaId: number;
109
+ fields: Record<string, any>;
110
+ };
111
+ declare function validateTLVsAgainstSchema(schema: Ats1SchemaDescriptor, tlvs: DecodedTlv[], depth?: number, limits?: Ats1Limits): void;
112
+ declare function logicalBodyToTLVs(schema: Ats1SchemaDescriptor, body: LogicalBody, limits?: Ats1Limits): DecodedTlv[];
113
+ declare function tlvsToLogicalBody(schema: Ats1SchemaDescriptor, tlvs: DecodedTlv[], limits?: Ats1Limits): LogicalBody;
114
+ declare const HDR_TAGS: {
115
+ readonly intent_id: 1;
116
+ readonly actor_key_id: 2;
117
+ readonly capsule_id: 3;
118
+ readonly nonce: 4;
119
+ readonly ts_ms: 5;
120
+ readonly schema_id: 6;
121
+ readonly body_hash: 7;
122
+ readonly trace_id: 8;
123
+ };
124
+ type AxisHeaderLogical = {
125
+ intentId: number;
126
+ actorKeyId: Uint8Array;
127
+ capsuleId?: Uint8Array;
128
+ nonce: Uint8Array;
129
+ tsMs: bigint;
130
+ schemaId: number;
131
+ bodyHash: Uint8Array;
132
+ traceId?: Uint8Array;
133
+ version?: number;
134
+ headerHash?: Uint8Array;
135
+ headerTlvs?: DecodedTlv[];
136
+ bodyTlvs?: DecodedTlv[];
137
+ };
138
+ type AxisLogicalRequest = {
139
+ hdr: AxisHeaderLogical;
140
+ body: LogicalBody;
141
+ };
142
+ declare function encodeAxisHeaderToTLVs(hdr: AxisHeaderLogical): DecodedTlv[];
143
+ declare function decodeAxisHeaderFromTLVs(hdrTlvs: DecodedTlv[], limits?: Ats1Limits): AxisHeaderLogical;
144
+ declare function encodeAxisRequestBinary(schema: Ats1SchemaDescriptor, req: Omit<AxisLogicalRequest, 'hdr'> & {
145
+ hdr: Omit<AxisHeaderLogical, 'bodyHash'>;
146
+ }, limits?: Ats1Limits): {
147
+ hdrBytes: Buffer;
148
+ bodyBytes: Buffer;
149
+ bodyHash: Buffer;
150
+ };
151
+ declare function decodeAxisRequestBinary(schema: Ats1SchemaDescriptor, hdrBytes: Buffer, bodyBytes: Buffer, limits?: Ats1Limits): {
152
+ hdr: AxisHeaderLogical;
153
+ body: LogicalBody;
154
+ sensorInput: SensorInputLike;
155
+ };
156
+ declare const Schema3100_DeviceContext: Ats1SchemaDescriptor;
157
+ declare const Schema2001_PasskeyLoginOptionsReq: Ats1SchemaDescriptor;
158
+ declare const Schema4001_LoginWithDeviceReq: Ats1SchemaDescriptor;
159
+
160
+ type ats1_Ats1FieldDescriptor = Ats1FieldDescriptor;
161
+ type ats1_Ats1FieldType = Ats1FieldType;
162
+ type ats1_Ats1Limits = Ats1Limits;
163
+ type ats1_Ats1SchemaDescriptor = Ats1SchemaDescriptor;
164
+ type ats1_AxisHeaderLogical = AxisHeaderLogical;
165
+ type ats1_AxisLogicalRequest = AxisLogicalRequest;
166
+ declare const ats1_DEFAULT_LIMITS: typeof DEFAULT_LIMITS;
167
+ type ats1_DecodedTlv = DecodedTlv;
168
+ type ats1_DecodedTlvMap = DecodedTlvMap;
169
+ declare const ats1_HDR_TAGS: typeof HDR_TAGS;
170
+ declare const ats1_Schema2001_PasskeyLoginOptionsReq: typeof Schema2001_PasskeyLoginOptionsReq;
171
+ declare const ats1_Schema3100_DeviceContext: typeof Schema3100_DeviceContext;
172
+ declare const ats1_Schema4001_LoginWithDeviceReq: typeof Schema4001_LoginWithDeviceReq;
173
+ type ats1_SensorInputLike = SensorInputLike;
174
+ declare const ats1_decodeAxisHeaderFromTLVs: typeof decodeAxisHeaderFromTLVs;
175
+ declare const ats1_decodeAxisRequestBinary: typeof decodeAxisRequestBinary;
176
+ declare const ats1_decodeTLVStream: typeof decodeTLVStream;
177
+ declare const ats1_decodeU64BE: typeof decodeU64BE;
178
+ declare const ats1_decodeUVarint: typeof decodeUVarint;
179
+ declare const ats1_encodeAxisHeaderToTLVs: typeof encodeAxisHeaderToTLVs;
180
+ declare const ats1_encodeAxisRequestBinary: typeof encodeAxisRequestBinary;
181
+ declare const ats1_encodeTLV: typeof encodeTLV;
182
+ declare const ats1_encodeTLVStreamCanonical: typeof encodeTLVStreamCanonical;
183
+ declare const ats1_encodeU64BE: typeof encodeU64BE;
184
+ declare const ats1_encodeUVarint: typeof encodeUVarint;
185
+ declare const ats1_logicalBodyToTLVs: typeof logicalBodyToTLVs;
186
+ declare const ats1_sha256: typeof sha256;
187
+ declare const ats1_tlvsToLogicalBody: typeof tlvsToLogicalBody;
188
+ declare const ats1_tlvsToMap: typeof tlvsToMap;
189
+ declare const ats1_validateTLVsAgainstSchema: typeof validateTLVsAgainstSchema;
190
+ declare namespace ats1 {
191
+ export { type ats1_Ats1FieldDescriptor as Ats1FieldDescriptor, type ats1_Ats1FieldType as Ats1FieldType, type ats1_Ats1Limits as Ats1Limits, type ats1_Ats1SchemaDescriptor as Ats1SchemaDescriptor, type ats1_AxisHeaderLogical as AxisHeaderLogical, type ats1_AxisLogicalRequest as AxisLogicalRequest, ats1_DEFAULT_LIMITS as DEFAULT_LIMITS, type ats1_DecodedTlv as DecodedTlv, type ats1_DecodedTlvMap as DecodedTlvMap, ats1_HDR_TAGS as HDR_TAGS, ats1_Schema2001_PasskeyLoginOptionsReq as Schema2001_PasskeyLoginOptionsReq, ats1_Schema3100_DeviceContext as Schema3100_DeviceContext, ats1_Schema4001_LoginWithDeviceReq as Schema4001_LoginWithDeviceReq, type ats1_SensorInputLike as SensorInputLike, ats1_decodeAxisHeaderFromTLVs as decodeAxisHeaderFromTLVs, ats1_decodeAxisRequestBinary as decodeAxisRequestBinary, ats1_decodeTLVStream as decodeTLVStream, ats1_decodeU64BE as decodeU64BE, ats1_decodeUVarint as decodeUVarint, ats1_encodeAxisHeaderToTLVs as encodeAxisHeaderToTLVs, ats1_encodeAxisRequestBinary as encodeAxisRequestBinary, ats1_encodeTLV as encodeTLV, ats1_encodeTLVStreamCanonical as encodeTLVStreamCanonical, ats1_encodeU64BE as encodeU64BE, ats1_encodeUVarint as encodeUVarint, ats1_logicalBodyToTLVs as logicalBodyToTLVs, ats1_sha256 as sha256, ats1_tlvsToLogicalBody as tlvsToLogicalBody, ats1_tlvsToMap as tlvsToMap, ats1_validateTLVsAgainstSchema as validateTLVsAgainstSchema };
192
+ }
193
+
194
+ declare function buildAts1Hdr(params: {
195
+ intentId: number;
196
+ schemaId: number;
197
+ actorKeyId?: Buffer;
198
+ capsuleId?: Buffer;
199
+ traceId?: Buffer;
200
+ tsMs?: bigint;
201
+ nonce?: Buffer;
202
+ bodyHash?: Buffer;
203
+ }): Buffer;
204
+ declare function packPasskeyLoginOptionsReq(params: {
205
+ intentId: number;
206
+ username: string;
207
+ actorKeyId?: Buffer;
208
+ capsuleId?: Buffer;
209
+ traceId?: Buffer;
210
+ }): {
211
+ hdr: Buffer<ArrayBufferLike>;
212
+ body: Buffer<ArrayBufferLike>;
213
+ };
214
+ declare function unpackPasskeyLoginOptionsReq(body: Buffer): {
215
+ username: string;
216
+ };
217
+ declare const Schema2021_PasskeyRegisterOptionsReq: Ats1SchemaDescriptor;
218
+ declare const Schema2011_PasskeyLoginVerifyReq: Ats1SchemaDescriptor;
219
+ declare function packPasskeyRegisterOptionsReq(params: {
220
+ intentId: number;
221
+ username: string;
222
+ actorKeyId?: Buffer;
223
+ traceId?: Buffer;
224
+ }): {
225
+ hdr: Buffer<ArrayBufferLike>;
226
+ body: Buffer<ArrayBufferLike>;
227
+ };
228
+ declare function unpackPasskeyRegisterOptionsReq(body: Buffer): {
229
+ username: string;
230
+ };
231
+ declare function packPasskeyLoginVerifyReq(params: {
232
+ intentId: number;
233
+ username: string;
234
+ credentialId: Buffer;
235
+ clientDataJSON: Buffer;
236
+ authenticatorData: Buffer;
237
+ signature: Buffer;
238
+ userHandle?: Buffer;
239
+ actorKeyId?: Buffer;
240
+ traceId?: Buffer;
241
+ }): {
242
+ hdr: Buffer<ArrayBufferLike>;
243
+ body: Buffer<ArrayBufferLike>;
244
+ };
245
+ declare function unpackPasskeyLoginVerifyReq(body: Buffer): {
246
+ username: string;
247
+ credentialId: Buffer;
248
+ clientDataJSON: Buffer;
249
+ authenticatorData: Buffer;
250
+ signature: Buffer;
251
+ userHandle: Buffer | undefined;
252
+ };
253
+ declare const Schema2002_PasskeyLoginOptionsRes: Ats1SchemaDescriptor;
254
+ declare function packPasskeyLoginOptionsRes(params: {
255
+ challenge: string;
256
+ timeout?: number;
257
+ rpId?: string;
258
+ userVerification?: string;
259
+ allowCredentials?: {
260
+ id: string;
261
+ type: string;
262
+ transports?: string[];
263
+ }[];
264
+ }): Buffer;
265
+ declare const Schema2012_PasskeyLoginVerifyRes: Ats1SchemaDescriptor;
266
+ declare function packPasskeyLoginVerifyRes(params: {
267
+ actorId: string;
268
+ keyId: string;
269
+ capsule: Buffer;
270
+ expiresAt: bigint;
271
+ }): Buffer;
272
+
273
+ type Axis1FrameToEncode = {
274
+ ver: number;
275
+ flags: number;
276
+ hdr: Buffer;
277
+ body: Buffer;
278
+ sig: Buffer;
279
+ };
280
+ declare function encodeAxis1Frame(f: Axis1FrameToEncode): Buffer;
281
+
282
+ declare function axis1SigningBytes(params: {
283
+ ver: number;
284
+ flags: number;
285
+ hdr: Buffer;
286
+ body: Buffer;
287
+ }): Buffer;
288
+
289
+ declare function encVarint(x: bigint): Buffer;
290
+ declare function varintU(x: number | bigint): Buffer;
291
+ declare function u64be(x: bigint): Buffer;
292
+ declare function utf8(s: string): Buffer;
293
+ declare function bytes(b: Uint8Array | Buffer): Buffer;
294
+ declare function nonce16(): Buffer;
295
+ declare function tlv(type: number, value: Buffer): Buffer;
296
+ declare function buildTLVs(items: {
297
+ type: number;
298
+ value: Buffer;
299
+ }[], opts?: {
300
+ allowDupTypes?: Set<number>;
301
+ }): Buffer;
302
+
303
+ declare function b64urlEncode(buf: Buffer): string;
304
+ declare function b64urlDecode(str: string): Buffer;
305
+ declare function b64urlEncodeString(str: string, encoding?: BufferEncoding): string;
306
+ declare function b64urlDecodeString(str: string, encoding?: BufferEncoding): string;
307
+
308
+ declare function canonicalJson(value: any): string;
309
+ declare function canonicalJsonExcluding(obj: Record<string, any>, exclude: string[]): string;
310
+
311
+ type AxisAlg = 'EdDSA' | 'ES256' | 'RS256';
312
+ type CapsuleStatus = 'ACTIVE' | 'CONSUMED' | 'REVOKED' | 'EXPIRED';
313
+ type CapsuleMode = 'SINGLE_USE' | 'MULTI_USE';
314
+ type KeyStatus = 'ACTIVE' | 'GRACE' | 'REVOKED' | 'RETIRED';
315
+ interface AxisSig {
316
+ alg: AxisAlg;
317
+ kid: string;
318
+ value: string;
319
+ }
320
+ interface AxisPacket$1<T = any> {
321
+ v: 1;
322
+ pid: string;
323
+ nonce: string;
324
+ ts: number;
325
+ actorId: string;
326
+ opcode: string;
327
+ body: T;
328
+ sig: AxisSig;
329
+ }
330
+ interface AxisCapsuleConstraints {
331
+ maxAmount?: number;
332
+ maxCount?: number;
333
+ ttlSeconds?: number;
334
+ ipCidrAllow?: string[];
335
+ countryAllow?: string[];
336
+ deviceIdAllow?: string[];
337
+ sessionIdLock?: string;
338
+ nonceRequired?: boolean;
339
+ }
340
+ interface TickWindow {
341
+ start: number;
342
+ end: number;
343
+ }
344
+ interface AxisCapsulePayload {
345
+ v: 1;
346
+ capsuleId: string;
347
+ actorId: string;
348
+ issuer: string;
349
+ audience: string;
350
+ subject?: string;
351
+ intent: string;
352
+ scopes: string[];
353
+ actions?: string[];
354
+ iat: number;
355
+ nbf?: number;
356
+ exp: number;
357
+ tickWindow?: TickWindow;
358
+ mode: CapsuleMode;
359
+ maxUses: number;
360
+ nonceSeed?: string;
361
+ policyRefs?: string[];
362
+ riskScore?: number;
363
+ constraints?: AxisCapsuleConstraints;
364
+ meta?: Record<string, unknown>;
365
+ }
366
+ interface AxisCapsule {
367
+ payload: AxisCapsulePayload;
368
+ sig: AxisSig;
369
+ }
370
+ interface CapsuleIssueBody {
371
+ intent: string;
372
+ audience: string;
373
+ scopes: string[];
374
+ subject?: string;
375
+ mode: CapsuleMode;
376
+ maxUses?: number;
377
+ expSeconds?: number;
378
+ constraints?: AxisCapsuleConstraints;
379
+ hints?: {
380
+ ip?: string;
381
+ ua?: string;
382
+ deviceId?: string;
383
+ geo?: string;
384
+ };
385
+ }
386
+ interface CapsuleBatchBody extends Omit<CapsuleIssueBody, 'mode' | 'maxUses'> {
387
+ count: number;
388
+ mode: 'SINGLE_USE';
389
+ }
390
+ interface IntentExecBody {
391
+ intent: string;
392
+ capsule: AxisCapsule;
393
+ execNonce?: string;
394
+ args: Record<string, any>;
395
+ }
396
+ interface CapsuleRevokeBody {
397
+ capsuleId: string;
398
+ reason: string;
399
+ }
400
+ interface AxisResponse<T = any> {
401
+ ok: boolean;
402
+ pid: string;
403
+ decisionId: string;
404
+ code: string;
405
+ message?: string;
406
+ data?: T;
407
+ meta?: Record<string, unknown>;
408
+ }
409
+ interface CapsuleIssueResult {
410
+ capsule: AxisCapsule;
411
+ }
412
+ interface CapsuleBatchResult {
413
+ capsules: AxisCapsule[];
414
+ }
415
+ interface ActorKeyRecord {
416
+ id: Buffer;
417
+ actor_id: string;
418
+ key_id: string;
419
+ algorithm: string;
420
+ public_key: Buffer;
421
+ purpose: string;
422
+ status: KeyStatus;
423
+ is_primary: boolean;
424
+ not_before: Date | null;
425
+ expires_at: Date | null;
426
+ rotated_from_key_id: string | null;
427
+ revoked_at: Date | null;
428
+ revocation_reason: string | null;
429
+ metadata: any;
430
+ created_at: Date;
431
+ updated_at: Date;
432
+ }
433
+ interface IssuerKeyRecord {
434
+ id: Buffer;
435
+ kid: string;
436
+ issuer_id: string;
437
+ alg: string;
438
+ public_key_pem: string;
439
+ status: KeyStatus;
440
+ not_before: Date | null;
441
+ not_after: Date | null;
442
+ fingerprint: string | null;
443
+ metadata: any;
444
+ created_at: Date;
445
+ updated_at: Date;
446
+ }
447
+ interface CapsuleRecord {
448
+ id: Buffer;
449
+ capsule_id: string;
450
+ actor_id: string;
451
+ intent: string;
452
+ audience: string;
453
+ issuer: string;
454
+ subject: string | null;
455
+ status: CapsuleStatus;
456
+ mode: CapsuleMode;
457
+ max_uses: number;
458
+ used_count: number;
459
+ iat: Date;
460
+ nbf: Date | null;
461
+ exp: Date;
462
+ scopes_json: any;
463
+ constraints_json: any;
464
+ policy_refs_json: any;
465
+ risk_score: number | null;
466
+ payload_hash: Buffer;
467
+ sig_alg: string;
468
+ sig_kid: string;
469
+ sig_value: Buffer;
470
+ created_at: Date;
471
+ updated_at: Date;
472
+ last_used_at: Date | null;
473
+ }
474
+
475
+ declare class ContractViolationError extends Error {
476
+ code: string;
477
+ constructor(code: string, message: string);
478
+ }
479
+ interface ExecutionMetrics {
480
+ dbWrites: number;
481
+ dbReads: number;
482
+ externalCalls: number;
483
+ elapsedMs: number;
484
+ }
485
+ declare class ExecutionMeter {
486
+ private dbWrites;
487
+ private dbReads;
488
+ private externalCalls;
489
+ private startTime;
490
+ private contract;
491
+ constructor(contract: any);
492
+ recordDbWrite(): void;
493
+ recordDbRead(): void;
494
+ recordExternalCall(): void;
495
+ checkTime(): void;
496
+ validateEffect(effect: string): void;
497
+ getMetrics(): ExecutionMetrics;
498
+ getContract(): any;
499
+ }
500
+
501
+ interface ExecutionContract {
502
+ maxDbWrites: number;
503
+ maxDbReads?: number;
504
+ maxExternalCalls: number;
505
+ maxTimeMs: number;
506
+ allowedEffects: string[];
507
+ maxMemoryMb?: number;
508
+ }
509
+ declare const DEFAULT_CONTRACTS: Record<string, ExecutionContract>;
510
+ declare const FALLBACK_CONTRACT: ExecutionContract;
511
+
512
+ type Axis1DecodedFrame = {
513
+ ver: number;
514
+ flags: number;
515
+ hdr: Buffer;
516
+ body: Buffer;
517
+ sig: Buffer;
518
+ frameSize: number;
519
+ };
520
+ declare function decodeAxis1Frame(buf: Buffer): Axis1DecodedFrame;
521
+
522
+ declare const T: {
523
+ INTENT: number;
524
+ PID: number;
525
+ INTENT_VERSION: number;
526
+ ACTOR_ID: number;
527
+ CAPSULE_ID: number;
528
+ NONCE: number;
529
+ TS_MS: number;
530
+ PROOF_TYPE: number;
531
+ BODY: number;
532
+ JSON: number;
533
+ };
534
+ type AxisPacket = {
535
+ intent: string;
536
+ intentVersion: number;
537
+ actorId: string;
538
+ capsuleId?: Buffer;
539
+ pid: Buffer;
540
+ nonce: Buffer;
541
+ tsMs: bigint;
542
+ headersMap: Map<number, Buffer[]>;
543
+ bodyMap: Map<number, Buffer[]>;
544
+ hdrBytes: Buffer;
545
+ bodyBytes: Buffer;
546
+ sig: Buffer;
547
+ };
548
+ declare function buildPacket(hdr: Buffer, body: Buffer, sig: Buffer, flags?: number): AxisPacket;
549
+
550
+ interface AxisObservedContext {
551
+ ip?: string;
552
+ ua?: string;
553
+ geo?: string;
554
+ }
555
+ interface AxisRequestContext {
556
+ observed: AxisObservedContext;
557
+ actorKeyKid?: string;
558
+ issuerKeyKid?: string;
559
+ decisionId: string;
560
+ actorId: string;
561
+ aud?: string;
562
+ opcode: string;
563
+ deviceId?: string;
564
+ sessionId?: string;
565
+ }
566
+
567
+ interface SensorPhaseMetadata {
568
+ phase: 'PRE_DECODE' | 'POST_DECODE';
569
+ dependencies?: string[];
570
+ asyncOk?: boolean;
571
+ cryptoOk?: boolean;
572
+ description?: string;
573
+ }
574
+ interface AxisSensor {
575
+ readonly name: string;
576
+ readonly order?: number;
577
+ phase?: SensorPhaseMetadata | 'PRE_DECODE' | 'POST_DECODE';
578
+ supports?(input: SensorInput): boolean;
579
+ run(input: SensorInput): Promise<SensorDecision>;
580
+ }
581
+ interface AxisSensorInit extends AxisSensor, OnModuleInit {
582
+ }
583
+ interface AxisPreSensor extends AxisSensor {
584
+ phase: 'PRE_DECODE';
585
+ }
586
+ interface AxisPostSensor extends AxisSensor {
587
+ phase: 'POST_DECODE';
588
+ }
589
+ interface SensorInput {
590
+ rawBytes?: Buffer | Uint8Array;
591
+ intent?: string;
592
+ ip?: string;
593
+ path?: string;
594
+ contentLength?: number;
595
+ peek?: Uint8Array;
596
+ country?: string;
597
+ clientId?: string;
598
+ isWs?: boolean;
599
+ metadata?: Record<string, any>;
600
+ actorId?: string;
601
+ opcode?: string;
602
+ aud?: string;
603
+ observed?: AxisObservedContext;
604
+ frameBody?: any;
605
+ deviceId?: string;
606
+ sessionId?: string;
607
+ packet?: Record<string, any>;
608
+ [key: string]: any;
609
+ }
610
+ declare enum Decision {
611
+ ALLOW = "ALLOW",
612
+ DENY = "DENY",
613
+ THROTTLE = "THROTTLE",
614
+ FLAG = "FLAG"
615
+ }
616
+ type SensorDecision = {
617
+ decision?: Decision;
618
+ allow: boolean;
619
+ riskScore: number;
620
+ reasons: string[];
621
+ code?: string;
622
+ retryAfterMs?: number;
623
+ scoreDelta?: number;
624
+ tags?: Record<string, any>;
625
+ meta?: any;
626
+ tighten?: {
627
+ expSecondsMax?: number;
628
+ constraintsPatch?: Record<string, any>;
629
+ };
630
+ } | {
631
+ action: 'ALLOW';
632
+ meta?: any;
633
+ } | {
634
+ action: 'DENY';
635
+ code: string;
636
+ reason?: string;
637
+ retryAfterMs?: number;
638
+ meta?: any;
639
+ } | {
640
+ action: 'THROTTLE';
641
+ retryAfterMs: number;
642
+ meta?: any;
643
+ } | {
644
+ action: 'FLAG';
645
+ scoreDelta: number;
646
+ reasons: string[];
647
+ meta?: any;
648
+ };
649
+ type SensorMinifiedDecision = {
650
+ allow: boolean;
651
+ riskScore: number;
652
+ reasons: string[];
653
+ tags?: Record<string, any>;
654
+ meta?: any;
655
+ tighten?: {
656
+ expSecondsMax?: number;
657
+ constraintsPatch?: Record<string, any>;
658
+ };
659
+ retryAfterMs?: number;
660
+ };
661
+ declare function normalizeSensorDecision(sensorDecision: SensorDecision): SensorMinifiedDecision;
662
+ declare const SensorDecisions: {
663
+ allow(meta?: any, tags?: Record<string, any>): SensorDecision;
664
+ deny(code: string, reason?: string, meta?: any): SensorDecision;
665
+ throttle(retryAfterMs: number, meta?: any): SensorDecision;
666
+ flag(scoreDelta: number, reasons: string[], meta?: any): SensorDecision;
667
+ };
668
+
42
669
  interface AxisHandler {
43
670
  readonly name: string;
44
671
  readonly open?: boolean;
@@ -56,4 +683,4 @@ interface AxisCrudHandler extends AxisHandlerInit {
56
683
  remove(body: Uint8Array, headers?: Map<number, Uint8Array>): Promise<Uint8Array>;
57
684
  }
58
685
 
59
- export { type AxisCrudHandler, type AxisEffect, type AxisFrame, type AxisHandler, type AxisHandlerInit, HANDLER_METADATA_KEY, Handler, INTENT_ROUTES_KEY, Intent, type IntentOptions, type IntentRoute, IntentRouter };
686
+ export { ATS1_HDR, ATS1_SCHEMA, type ActorKeyRecord, ats1 as Ats1Codec, type Axis1DecodedFrame, type Axis1FrameToEncode, type AxisAlg, type AxisPacket as AxisBinaryPacket, type AxisCapsule, type AxisCapsuleConstraints, type AxisCapsulePayload, type AxisCrudHandler, type AxisEffect, AxisFrame, type AxisHandler, type AxisHandlerInit, type AxisObservedContext, type AxisPacket$1 as AxisPacket, T as AxisPacketTags, type AxisPostSensor, type AxisPreSensor, type AxisRequestContext, type AxisResponse, type AxisSensor, type AxisSensorInit, type AxisSig, type CapsuleBatchBody, type CapsuleBatchResult, type CapsuleIssueBody, type CapsuleIssueResult, type CapsuleMode, type CapsuleRecord, type CapsuleRevokeBody, type CapsuleStatus, ContractViolationError, DEFAULT_CONTRACTS, Decision, type ExecutionContract, ExecutionMeter, type ExecutionMetrics, FALLBACK_CONTRACT, HANDLER_METADATA_KEY, Handler, INTENT_ROUTES_KEY, Intent, type IntentExecBody, type IntentOptions, type IntentRoute, IntentRouter, type IssuerKeyRecord, type KeyStatus, Schema2002_PasskeyLoginOptionsRes, Schema2011_PasskeyLoginVerifyReq, Schema2012_PasskeyLoginVerifyRes, Schema2021_PasskeyRegisterOptionsReq, type SensorDecision, SensorDecisions, type SensorInput, type SensorMinifiedDecision, type SensorPhaseMetadata, type TickWindow, axis1SigningBytes, b64urlDecode, b64urlDecodeString, b64urlEncode, b64urlEncodeString, buildAts1Hdr, buildPacket, buildTLVs, bytes, canonicalJson, canonicalJsonExcluding, decodeAxis1Frame, encVarint, encodeAxis1Frame, nonce16, normalizeSensorDecision, packPasskeyLoginOptionsReq, packPasskeyLoginOptionsRes, packPasskeyLoginVerifyReq, packPasskeyLoginVerifyRes, packPasskeyRegisterOptionsReq, tlv, u64be, unpackPasskeyLoginOptionsReq, unpackPasskeyLoginVerifyReq, unpackPasskeyRegisterOptionsReq, utf8, varintU };