blockintel-gate-sdk 0.3.8 → 0.3.9

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.cts CHANGED
@@ -1,338 +1,7 @@
1
1
  import * as _aws_sdk_client_kms from '@aws-sdk/client-kms';
2
- import { SignCommandInput, KMSClient } from '@aws-sdk/client-kms';
3
-
4
- /**
5
- * Metrics Collector for SDK
6
- *
7
- * Collects counters and latency metrics for observability.
8
- */
9
- interface Metrics {
10
- requestsTotal: number;
11
- allowedTotal: number;
12
- blockedTotal: number;
13
- stepupTotal: number;
14
- timeoutsTotal: number;
15
- errorsTotal: number;
16
- circuitBreakerOpenTotal: number;
17
- wouldBlockTotal: number;
18
- failOpenTotal: number;
19
- latencyMs: number[];
20
- }
21
- type MetricsHook = (metrics: Metrics) => void | Promise<void>;
22
- /**
23
- * Metrics Collector
24
- */
25
- declare class MetricsCollector {
26
- private requestsTotal;
27
- private allowedTotal;
28
- private blockedTotal;
29
- private stepupTotal;
30
- private timeoutsTotal;
31
- private errorsTotal;
32
- private circuitBreakerOpenTotal;
33
- private wouldBlockTotal;
34
- private failOpenTotal;
35
- private latencyMs;
36
- private readonly maxSamples;
37
- private readonly hooks;
38
- /**
39
- * Record a request
40
- */
41
- recordRequest(decision: 'ALLOW' | 'BLOCK' | 'REQUIRE_STEP_UP' | 'WOULD_BLOCK' | 'FAIL_OPEN', latencyMs: number): void;
42
- /**
43
- * Record a timeout
44
- */
45
- recordTimeout(): void;
46
- /**
47
- * Record an error
48
- */
49
- recordError(): void;
50
- /**
51
- * Record circuit breaker open
52
- */
53
- recordCircuitBreakerOpen(): void;
54
- /**
55
- * Get current metrics snapshot
56
- */
57
- getMetrics(): Metrics;
58
- /**
59
- * Register a metrics hook (e.g., for Prometheus/OpenTelemetry export)
60
- */
61
- registerHook(hook: MetricsHook): void;
62
- /**
63
- * Emit metrics to all registered hooks
64
- */
65
- private emitMetrics;
66
- /**
67
- * Reset all metrics
68
- */
69
- reset(): void;
70
- }
71
-
72
- /**
73
- * BlockIntel Gate SDK - Type Contracts
74
- *
75
- * Type definitions for Gate Hot Path API v2 contracts.
76
- * Internal SDK uses camelCase; mapping to/from API snake_case is handled internally.
77
- */
78
- /**
79
- * Transaction intent structure for evaluate request
80
- */
81
- interface TransactionIntentV2 {
82
- from: string;
83
- to: string;
84
- value?: string;
85
- data?: string;
86
- nonce?: number | string;
87
- gasPrice?: string;
88
- gasLimit?: string;
89
- chainId?: number | string;
90
- [key: string]: unknown;
91
- }
92
- /**
93
- * Signing context metadata
94
- */
95
- interface SigningContext {
96
- signerId?: string;
97
- source?: {
98
- repo?: string;
99
- workflow?: string;
100
- environment?: string;
101
- [key: string]: unknown;
102
- };
103
- wallet?: {
104
- address: string;
105
- type?: string;
106
- [key: string]: unknown;
107
- };
108
- [key: string]: unknown;
109
- }
110
- /**
111
- * Defense evaluate request (v2)
112
- */
113
- interface DefenseEvaluateRequestV2 {
114
- txIntent: TransactionIntentV2;
115
- signingContext?: SigningContext;
116
- requestId?: string;
117
- timestampMs?: number;
118
- /**
119
- * Enable transaction simulation (optional, defaults to false)
120
- *
121
- * When true, Hot Path will simulate the transaction after static policy evaluation.
122
- * Adds 300-800ms latency but provides additional security checks.
123
- */
124
- simulate?: boolean;
125
- }
126
- /**
127
- * Gate decision types
128
- */
129
- type GateDecision = 'ALLOW' | 'BLOCK' | 'REQUIRE_STEP_UP';
130
- /**
131
- * Step-up metadata in evaluate response
132
- */
133
- interface StepUpMetadata {
134
- requestId: string;
135
- ttlSeconds?: number;
136
- }
137
- /**
138
- * Defense evaluate response (v2)
139
- */
140
- interface DefenseEvaluateResponseV2 {
141
- decision: GateDecision;
142
- reasonCodes: string[];
143
- policyVersion?: string;
144
- correlationId?: string;
145
- decisionId?: string;
146
- stepUp?: StepUpMetadata;
147
- /**
148
- * Decision token (JWS HS256) binding decision to txDigest. Required in ENFORCE/HARD when requireDecisionToken.
149
- */
150
- decisionToken?: string;
151
- /**
152
- * Unix seconds when decision token expires.
153
- */
154
- expiresAt?: number;
155
- /**
156
- * SHA256(canonicalJson(txBinding)). Must match when signing.
157
- */
158
- txDigest?: string;
159
- /**
160
- * Whether the decision was enforced (false in SHADOW mode)
161
- */
162
- enforced?: boolean;
163
- /**
164
- * Whether shadow mode would have blocked (true if mode=SHADOW and decision=BLOCK)
165
- */
166
- shadowWouldBlock?: boolean;
167
- /**
168
- * Gate mode used for this evaluation
169
- */
170
- mode?: GateMode;
171
- /**
172
- * Metadata (evaluation latency, simulation, policy hash for pinning)
173
- */
174
- metadata?: {
175
- evaluationLatencyMs?: number;
176
- policyHash?: string;
177
- snapshotVersion?: number;
178
- [key: string]: unknown;
179
- };
180
- }
181
- /**
182
- * Step-up status types
183
- */
184
- type GateStepUpStatus = 'PENDING' | 'APPROVED' | 'DENIED' | 'EXPIRED';
185
- /**
186
- * Step-up status response
187
- */
188
- interface StepUpStatusResponse {
189
- status: GateStepUpStatus;
190
- tenantId: string;
191
- requestId: string;
192
- decision?: string;
193
- reasonCodes?: string[];
194
- correlationId?: string;
195
- expiresAtMs?: number;
196
- ttl?: number;
197
- }
198
- /**
199
- * Final result from awaitStepUpDecision
200
- */
201
- interface StepUpFinalResult {
202
- status: GateStepUpStatus;
203
- requestId: string;
204
- elapsedMs: number;
205
- decision?: string;
206
- reasonCodes?: string[];
207
- correlationId?: string;
208
- }
209
- /**
210
- * Fail-safe mode for SDK (deprecated - use onConnectionFailure instead)
211
- */
212
- type FailSafeMode = 'ALLOW_ON_TIMEOUT' | 'BLOCK_ON_TIMEOUT' | 'BLOCK_ON_ANOMALY';
213
- /**
214
- * Gate Mode
215
- *
216
- * SHADOW: Evaluate and log, but always allow (monitor-only)
217
- * ENFORCE: Evaluate and enforce decisions (block if policy violation)
218
- */
219
- type GateMode = 'SHADOW' | 'ENFORCE';
220
- /**
221
- * Connection Failure Strategy
222
- *
223
- * FAIL_OPEN: Allow transaction if hotpath is unreachable
224
- * FAIL_CLOSED: Block transaction if hotpath is unreachable (security-first)
225
- */
226
- type ConnectionFailureStrategy = 'FAIL_OPEN' | 'FAIL_CLOSED';
227
- /**
228
- * Circuit breaker configuration
229
- */
230
- interface CircuitBreakerConfig$1 {
231
- tripAfterConsecutiveFailures?: number;
232
- coolDownMs?: number;
233
- }
234
- /**
235
- * SDK client configuration
236
- */
237
- interface GateClientConfig {
238
- baseUrl: string;
239
- tenantId: string;
240
- auth: {
241
- mode: 'hmac';
242
- keyId: string;
243
- secret: string;
244
- } | {
245
- mode: 'apiKey';
246
- apiKey: string;
247
- };
248
- timeoutMs?: number;
249
- userAgent?: string;
250
- clockSkewMs?: number;
251
- retries?: number;
252
- failSafeMode?: FailSafeMode;
253
- /**
254
- * Gate mode (default: SHADOW for safety)
255
- *
256
- * SHADOW: Monitor-only - evaluate and log, but always allow
257
- * ENFORCE: Enforce decisions - block if policy violation
258
- */
259
- mode?: GateMode;
260
- /**
261
- * Connection failure strategy (default: based on mode)
262
- *
263
- * FAIL_OPEN: Allow on connection failure (default in SHADOW mode)
264
- * FAIL_CLOSED: Block on connection failure (default in ENFORCE mode)
265
- */
266
- onConnectionFailure?: ConnectionFailureStrategy;
267
- circuitBreaker?: CircuitBreakerConfig$1;
268
- enableStepUp?: boolean;
269
- stepUp?: {
270
- pollingIntervalMs?: number;
271
- maxWaitMs?: number;
272
- treatRequireStepUpAsBlockWhenDisabled?: boolean;
273
- };
274
- onMetrics?: (metrics: Metrics) => void | Promise<void>;
275
- signerId?: string;
276
- heartbeatRefreshIntervalSeconds?: number;
277
- /** API key for Control Plane heartbeat endpoint (x-gate-heartbeat-key). Required when not local. Fallback: GATE_HEARTBEAT_KEY env. */
278
- heartbeatApiKey?: string;
279
- /** When true or GATE_SDK_DEBUG=1, log sanitized request/response (no secrets, no body values). */
280
- debug?: boolean;
281
- /**
282
- * Break-glass token (optional, for emergency override)
283
- *
284
- * JWT token issued by Control Plane for time-bound policy bypass.
285
- * Only valid if explicitly activated via break-glass endpoint.
286
- */
287
- breakglassToken?: string;
288
- /**
289
- * Local development mode - disables auth, heartbeat, and break-glass
290
- * Set to true when using gate-local emulator
291
- */
292
- local?: boolean;
293
- /**
294
- * Enforcement mode (default: SOFT)
295
- *
296
- * SOFT: Warns if IAM permission risk detected, but allows initialization
297
- * HARD: Blocks initialization if IAM permission risk detected (unless override set)
298
- */
299
- enforcementMode?: 'SOFT' | 'HARD';
300
- /**
301
- * Allow initialization even if IAM permission risk detected
302
- *
303
- * Default: false in HARD mode, true in SOFT mode
304
- *
305
- * WARNING: Setting to true in HARD mode defeats the purpose of hard enforcement.
306
- * Only use during migration periods.
307
- */
308
- allowInsecureKmsSignPermission?: boolean;
309
- /**
310
- * Optional: Specific KMS key IDs to check for permission risk
311
- * If not provided, checks for any kms:Sign permission
312
- */
313
- kmsKeyIds?: string[];
314
- /**
315
- * Require decision token before sign (default: true when mode=ENFORCE or enforcementMode=HARD).
316
- * When true, evaluate() must return decisionToken/txDigest for ALLOW; sign path verifies digest match.
317
- * Override with GATE_REQUIRE_DECISION_TOKEN env.
318
- */
319
- requireDecisionToken?: boolean;
320
- /**
321
- * Optional policy pinning: if set, evaluate response must have matching policyHash (from metadata).
322
- * Mismatch → treat as BLOCK locally (do not call signer). Defense against Control Plane compromise.
323
- */
324
- expectedPolicyHash?: string;
325
- /**
326
- * Optional snapshot version pinning: if set, evaluate response must have matching snapshotVersion (from metadata).
327
- * Mismatch → treat as BLOCK locally.
328
- */
329
- expectedSnapshotVersion?: number;
330
- /**
331
- * Optional: public key (PEM) to verify RS256 decision tokens. When set, ALLOW responses with decisionToken
332
- * are signature-verified; invalid or wrong-key tokens are treated as BLOCK.
333
- */
334
- decisionTokenPublicKey?: string;
335
- }
2
+ import { SignCommandInput, KMSClient, SigningAlgorithmSpec } from '@aws-sdk/client-kms';
3
+ import { G as GateClientConfig, D as DefenseEvaluateRequestV2, a as DefenseEvaluateResponseV2, M as MetricsCollector, S as StepUpStatusResponse, b as StepUpFinalResult, c as SigningContext, A as AttestCompletedRequest, d as AttestCompletedResponse } from './contracts-KKk945Ox.cjs';
4
+ export { E as EvaluationMode, e as GateDecision, f as GateMode, h as GateStepUpStatus, g as StepUpMetadata, T as TransactionIntentV2 } from './contracts-KKk945Ox.cjs';
336
5
 
337
6
  /**
338
7
  * Circuit Breaker for SDK
@@ -466,6 +135,77 @@ interface WrappedKmsClient extends KMSClient {
466
135
  */
467
136
  declare function wrapKmsClient(kmsClient: KMSClient, gateClient: GateClient, options?: WrapKmsClientOptions): WrappedKmsClient;
468
137
 
138
+ /**
139
+ * Signer Backend Interface
140
+ *
141
+ * Abstract interface for cryptographic signing backends (AWS KMS, HashiCorp Vault, GCP KMS, etc.)
142
+ */
143
+ interface SignRequest {
144
+ /**
145
+ * Key identifier (KMS key ID, Vault key name, GCP key name, etc.)
146
+ */
147
+ keyId: string;
148
+ /**
149
+ * Message to sign (raw bytes)
150
+ */
151
+ message: Buffer | Uint8Array;
152
+ /**
153
+ * Signing algorithm
154
+ * - AWS KMS: ECDSA_SHA_256, ECDSA_SHA_384, ECDSA_SHA_512, RSASSA_PSS_SHA_256, etc.
155
+ * - Vault: ecdsa-sha2-256, ecdsa-sha2-384, ecdsa-sha2-512, rsa-sha2-256, etc.
156
+ * - GCP: EC_SIGN_P256_SHA256, EC_SIGN_P384_SHA384, RSA_SIGN_PSS_2048_SHA256, etc.
157
+ */
158
+ algorithm?: string;
159
+ /**
160
+ * Message type (RAW, DIGEST, etc.)
161
+ */
162
+ messageType?: string;
163
+ /**
164
+ * Additional backend-specific options
165
+ */
166
+ options?: Record<string, any>;
167
+ }
168
+ interface SignResponse {
169
+ /**
170
+ * Signature bytes
171
+ */
172
+ signature: Buffer | Uint8Array;
173
+ /**
174
+ * Key ID used for signing
175
+ */
176
+ keyId: string;
177
+ /**
178
+ * Signing algorithm used
179
+ */
180
+ algorithm: string;
181
+ /**
182
+ * Additional metadata
183
+ */
184
+ metadata?: Record<string, any>;
185
+ }
186
+ /**
187
+ * Signer Backend Interface
188
+ *
189
+ * All signing backends must implement this interface.
190
+ */
191
+ interface SignerBackend {
192
+ /**
193
+ * Sign a message
194
+ *
195
+ * @param request Sign request
196
+ * @returns Sign response with signature
197
+ */
198
+ sign(request: SignRequest): Promise<SignResponse>;
199
+ /**
200
+ * Get backend name for logging
201
+ */
202
+ getName(): string;
203
+ /**
204
+ * Check if backend is available/configured
205
+ */
206
+ isAvailable(): boolean;
207
+ }
208
+
469
209
  /**
470
210
  * Gate Client for Hot Path API
471
211
  */
@@ -534,6 +274,27 @@ declare class GateClient {
534
274
  maxWaitMs?: number;
535
275
  intervalMs?: number;
536
276
  }): Promise<StepUpFinalResult>;
277
+ /**
278
+ * Evaluate policy and sign in one call when decision is ALLOW.
279
+ * Convenience for: evaluate → if ALLOW then sign → return { decision, signature }.
280
+ */
281
+ evaluateAndSign(params: {
282
+ txIntent: DefenseEvaluateRequestV2['txIntent'];
283
+ signer: SignerBackend;
284
+ keyId: string;
285
+ message: Buffer | Uint8Array;
286
+ algorithm?: string;
287
+ signingContext?: SigningContext;
288
+ }): Promise<{
289
+ decision: DefenseEvaluateResponseV2;
290
+ signature?: SignResponse;
291
+ }>;
292
+ /**
293
+ * Attest a completed signature (post-sign). Use when you want zero latency impact on signing
294
+ * but still want an audit trail. Policy is evaluated against txIntent; returns ALLOW or
295
+ * POLICY_VIOLATION_DETECTED. Cannot be used for enforcement (signature already created).
296
+ */
297
+ attestCompleted(req: AttestCompletedRequest): Promise<AttestCompletedResponse>;
537
298
  /**
538
299
  * Wrap AWS SDK v3 KMS client to intercept SignCommand calls
539
300
  *
@@ -560,21 +321,26 @@ declare class GateClient {
560
321
  declare function createGateClient(config: GateClientConfig): GateClient;
561
322
 
562
323
  /**
563
- * Gate - Simplified API for Nexus-style injection
324
+ * Gate - Simplified API for Nexus-style injection and 5-line integration
564
325
  *
565
- * Provides a drop-in compatible API for code injected by Nexus:
566
- * import { Gate } from "blockintel-gate-sdk";
567
- * const gate = new Gate({ apiKey: process.env.BLOCKINTEL_API_KEY });
568
- * const tx = await gate.guard(ctx, async () => wallet.sendTransaction({ ... }));
326
+ * - Gate.fromEnv(): Create a GateClient from env vars (GATE_BASE_URL, GATE_TENANT_ID,
327
+ * GATE_API_KEY or GATE_KEY_ID+GATE_HMAC_SECRET, GATE_MODE). Enables true 5-line integration.
328
+ * - new Gate({ apiKey }): Passthrough guard for Nexus-injected code.
569
329
  *
570
- * In passthrough mode (no baseUrl/tenantId, or Nexus sandbox): executes the callback.
571
330
  * For full policy evaluation, use GateClient.evaluate() with tx params before sending.
572
331
  */
332
+
573
333
  declare class Gate {
574
334
  private readonly apiKey?;
575
335
  constructor(opts?: {
576
336
  apiKey?: string;
577
337
  });
338
+ /**
339
+ * Create a GateClient from environment variables (5-line integration).
340
+ *
341
+ * Reads: GATE_BASE_URL, GATE_TENANT_ID, GATE_API_KEY (or GATE_KEY_ID + GATE_HMAC_SECRET), GATE_MODE.
342
+ */
343
+ static fromEnv(overrides?: Partial<GateClientConfig>): GateClient;
578
344
  /**
579
345
  * Guard a signing operation. In passthrough mode, executes the callback.
580
346
  * For full Gate integration, use GateClient with evaluate() before sending.
@@ -888,4 +654,242 @@ declare function buildTxBindingObject(txIntent: {
888
654
  */
889
655
  declare function computeTxDigest(binding: TxBindingObject): string;
890
656
 
891
- export { BlockIntelAuthError, BlockIntelBlockedError, BlockIntelStepUpRequiredError, BlockIntelUnavailableError, type DefenseEvaluateRequestV2, type DefenseEvaluateResponseV2, Gate, GateClient, type GateClientConfig, type GateDecision, GateError, GateErrorCode, type GateStepUpStatus, HeartbeatManager, type HeartbeatToken, type Provenance, ProvenanceProvider, type SigningContext, type StepUpFinalResult, type StepUpMetadata, StepUpNotConfiguredError, type StepUpStatusResponse, type TransactionIntentV2, type TxBindingObject, type WrapKmsClientOptions, type WrappedKmsClient, buildTxBindingObject, computeTxDigest, createGateClient, GateClient as default, wrapKmsClient };
657
+ /**
658
+ * AWS KMS Signer Backend
659
+ *
660
+ * Implements SignerBackend for AWS KMS using AWS SDK v3
661
+ */
662
+
663
+ interface AwsKmsSignerConfig {
664
+ /**
665
+ * AWS KMS client instance
666
+ */
667
+ kmsClient: KMSClient;
668
+ /**
669
+ * Default signing algorithm (if not specified in request)
670
+ */
671
+ defaultAlgorithm?: SigningAlgorithmSpec;
672
+ /**
673
+ * Default message type (if not specified in request)
674
+ */
675
+ defaultMessageType?: 'RAW' | 'DIGEST';
676
+ }
677
+ /**
678
+ * AWS KMS Signer Backend
679
+ */
680
+ declare class AwsKmsSigner implements SignerBackend {
681
+ private readonly config;
682
+ constructor(config: AwsKmsSignerConfig);
683
+ getName(): string;
684
+ isAvailable(): boolean;
685
+ sign(request: SignRequest): Promise<SignResponse>;
686
+ /**
687
+ * Map algorithm string to AWS KMS SigningAlgorithmSpec
688
+ */
689
+ private mapAlgorithm;
690
+ }
691
+
692
+ /**
693
+ * HashiCorp Vault Signer Backend
694
+ *
695
+ * Implements SignerBackend for HashiCorp Vault Transit Engine
696
+ */
697
+
698
+ interface VaultSignerConfig {
699
+ /**
700
+ * Vault API base URL (e.g., 'https://vault.example.com:8200')
701
+ */
702
+ vaultUrl: string;
703
+ /**
704
+ * Vault authentication token
705
+ */
706
+ token?: string;
707
+ /**
708
+ * Vault AppRole authentication (alternative to token)
709
+ */
710
+ appRole?: {
711
+ roleId: string;
712
+ secretId: string;
713
+ };
714
+ /**
715
+ * Transit engine mount path (default: 'transit')
716
+ */
717
+ mountPath?: string;
718
+ /**
719
+ * Default signing algorithm (if not specified in request)
720
+ */
721
+ defaultAlgorithm?: string;
722
+ /**
723
+ * HTTP client options (timeout, etc.)
724
+ */
725
+ httpOptions?: {
726
+ timeout?: number;
727
+ };
728
+ }
729
+ /**
730
+ * HashiCorp Vault Signer Backend
731
+ */
732
+ declare class VaultSigner implements SignerBackend {
733
+ private readonly config;
734
+ private authToken;
735
+ constructor(config: VaultSignerConfig);
736
+ getName(): string;
737
+ isAvailable(): boolean;
738
+ sign(request: SignRequest): Promise<SignResponse>;
739
+ /**
740
+ * Authenticate using AppRole
741
+ */
742
+ private authenticateAppRole;
743
+ /**
744
+ * Map algorithm string to Vault format
745
+ */
746
+ private mapAlgorithm;
747
+ }
748
+
749
+ /**
750
+ * Google Cloud KMS Signer Backend
751
+ *
752
+ * Implements SignerBackend for Google Cloud KMS
753
+ */
754
+
755
+ interface GcpKmsSignerConfig {
756
+ /**
757
+ * GCP project ID
758
+ */
759
+ projectId: string;
760
+ /**
761
+ * GCP location (e.g., 'us-east1', 'global')
762
+ */
763
+ location: string;
764
+ /**
765
+ * Key ring name
766
+ */
767
+ keyRing: string;
768
+ /**
769
+ * Service account credentials (JSON key file content or path)
770
+ */
771
+ credentials?: string | {
772
+ client_email: string;
773
+ private_key: string;
774
+ };
775
+ /**
776
+ * Use workload identity (default: false)
777
+ * When true, uses GCP metadata service for authentication
778
+ */
779
+ useWorkloadIdentity?: boolean;
780
+ /**
781
+ * Default signing algorithm (if not specified in request)
782
+ */
783
+ defaultAlgorithm?: string;
784
+ /**
785
+ * HTTP client options (timeout, etc.)
786
+ */
787
+ httpOptions?: {
788
+ timeout?: number;
789
+ };
790
+ }
791
+ /**
792
+ * Google Cloud KMS Signer Backend
793
+ */
794
+ declare class GcpKmsSigner implements SignerBackend {
795
+ private readonly config;
796
+ private accessToken;
797
+ private tokenExpiry;
798
+ constructor(config: GcpKmsSignerConfig);
799
+ getName(): string;
800
+ isAvailable(): boolean;
801
+ sign(request: SignRequest): Promise<SignResponse>;
802
+ /**
803
+ * Get GCP access token
804
+ */
805
+ private getAccessToken;
806
+ /**
807
+ * Map algorithm string to GCP format
808
+ */
809
+ private mapAlgorithm;
810
+ }
811
+
812
+ /**
813
+ * Fireblocks Signer Backend
814
+ *
815
+ * Implements SignerBackend for Fireblocks API.
816
+ * Key ID format: fireblocks://vaultAccountId/assetId
817
+ * Docs: https://developers.fireblocks.com/reference/post_transactions
818
+ */
819
+
820
+ interface FireblocksSignerConfig {
821
+ /** Fireblocks API base URL (default: https://api.fireblocks.io) */
822
+ apiBaseUrl?: string;
823
+ /** Fireblocks API key (API User ID) */
824
+ apiKey: string;
825
+ /** Fireblocks API secret (private key PEM) */
826
+ apiSecret: string;
827
+ /** Default vault account ID (optional) */
828
+ vaultAccountId?: string;
829
+ }
830
+ declare class FireblocksSigner implements SignerBackend {
831
+ private readonly config;
832
+ private readonly apiBaseUrl;
833
+ constructor(config: FireblocksSignerConfig);
834
+ getName(): string;
835
+ isAvailable(): boolean;
836
+ sign(request: SignRequest): Promise<SignResponse>;
837
+ /**
838
+ * Create JWT for Fireblocks API (RS256, uri + bodyHash in payload).
839
+ */
840
+ private createAuthToken;
841
+ private pollTransaction;
842
+ }
843
+
844
+ /**
845
+ * PKCS#11 session implementation using pkcs11js.
846
+ *
847
+ * When the optional dependency `pkcs11js` is installed, this class loads the
848
+ * PKCS#11 library (e.g. SoftHSM2, Thales nShield, Utimaco, AWS CloudHSM),
849
+ * opens a session, and performs sign operations. Without pkcs11js, use a
850
+ * custom pkcs11Session in GenericHsmSigner or install: npm install pkcs11js
851
+ */
852
+ interface Pkcs11SessionInitOptions {
853
+ /** Slot index (default 0). Use when multiple tokens are present. */
854
+ slotId?: number;
855
+ }
856
+ interface Pkcs11Session {
857
+ initialize(libraryPath: string, pin: string, options?: Pkcs11SessionInitOptions): Promise<void>;
858
+ sign(keyHandle: Buffer, mechanism: string, data: Buffer): Promise<Buffer>;
859
+ close(): Promise<void>;
860
+ }
861
+
862
+ /**
863
+ * Generic HSM Signer Backend (PKCS#11)
864
+ *
865
+ * Abstraction for on-prem HSMs via PKCS#11 (Thales nShield, Utimaco, AWS CloudHSM, etc.).
866
+ * Key ID format: hsm://<keyHandle> where keyHandle is hex-encoded.
867
+ *
868
+ * Requires a PKCS#11 session implementation. Use config.pkcs11Session for testing or
869
+ * a real adapter; otherwise Pkcs11SessionImpl throws until a PKCS#11 library is linked.
870
+ */
871
+
872
+ interface GenericHsmSignerConfig {
873
+ /** PKCS#11 library path (e.g. /usr/lib/libCryptoki2_64.so for Thales) */
874
+ pkcs11LibraryPath: string;
875
+ /** HSM slot ID (optional) */
876
+ slotId?: number;
877
+ /** PIN / password */
878
+ pin: string;
879
+ /** Optional: custom PKCS#11 session (for testing or custom HSM adapters) */
880
+ pkcs11Session?: Pkcs11Session;
881
+ }
882
+ declare class GenericHsmSigner implements SignerBackend {
883
+ private readonly config;
884
+ private session;
885
+ constructor(config: GenericHsmSignerConfig);
886
+ getName(): string;
887
+ isAvailable(): boolean;
888
+ sign(request: SignRequest): Promise<SignResponse>;
889
+ private initializePkcs11Session;
890
+ private mapAlgorithmToMechanism;
891
+ /** Release the PKCS#11 session. Call when done to free resources. */
892
+ close(): Promise<void>;
893
+ }
894
+
895
+ export { AttestCompletedRequest, AttestCompletedResponse, AwsKmsSigner, BlockIntelAuthError, BlockIntelBlockedError, BlockIntelStepUpRequiredError, BlockIntelUnavailableError, DefenseEvaluateRequestV2, DefenseEvaluateResponseV2, FireblocksSigner, type FireblocksSignerConfig, Gate, GateClient, GateClientConfig, GateError, GateErrorCode, GcpKmsSigner, GenericHsmSigner, type GenericHsmSignerConfig, HeartbeatManager, type HeartbeatToken, type Pkcs11Session, type Provenance, ProvenanceProvider, type SignRequest, type SignResponse, type SignerBackend, SigningContext, StepUpFinalResult, StepUpNotConfiguredError, StepUpStatusResponse, type TxBindingObject, VaultSigner, type WrapKmsClientOptions, type WrappedKmsClient, buildTxBindingObject, computeTxDigest, createGateClient, GateClient as default, wrapKmsClient };