kontext-sdk 0.9.0 → 0.11.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 +57 -236
- package/dist/index.d.mts +492 -5
- package/dist/index.d.ts +492 -5
- package/dist/index.js +1214 -37
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1204 -36
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -434,6 +434,30 @@ interface KontextConfig {
|
|
|
434
434
|
* $10K CTR, $50K large transaction).
|
|
435
435
|
*/
|
|
436
436
|
policy?: PolicyConfig;
|
|
437
|
+
/**
|
|
438
|
+
* Default agent ID for verify/log calls when not specified per-call.
|
|
439
|
+
* Set automatically when loading from kontext.config.json.
|
|
440
|
+
*/
|
|
441
|
+
agentId?: string;
|
|
442
|
+
/**
|
|
443
|
+
* Wallet monitoring configuration. When provided, SDK watches these
|
|
444
|
+
* addresses on-chain for stablecoin transfers and auto-calls verify().
|
|
445
|
+
* Requires viem as a peer dependency.
|
|
446
|
+
*/
|
|
447
|
+
walletMonitoring?: WalletMonitoringConfig;
|
|
448
|
+
/**
|
|
449
|
+
* Viem interceptor mode for withKontextCompliance() (default: 'post-send').
|
|
450
|
+
* - 'post-send': verify() runs after tx succeeds, never blocks
|
|
451
|
+
* - 'pre-send': verify() runs before tx, throws if non-compliant
|
|
452
|
+
* - 'both': pre-send screening + post-send full verify
|
|
453
|
+
*/
|
|
454
|
+
interceptorMode?: 'post-send' | 'pre-send' | 'both';
|
|
455
|
+
/**
|
|
456
|
+
* Wallet provider configuration. When provided, SDK initializes the
|
|
457
|
+
* corresponding wallet manager (Circle, Coinbase, or MetaMask) for
|
|
458
|
+
* compliance-wrapped wallet operations.
|
|
459
|
+
*/
|
|
460
|
+
walletProvider?: WalletProviderConfig;
|
|
437
461
|
}
|
|
438
462
|
/** Screening configuration for pluggable multi-provider sanctions screening */
|
|
439
463
|
interface ScreeningConfig {
|
|
@@ -473,6 +497,150 @@ interface PolicyConfig {
|
|
|
473
497
|
/** When true, refuse verify() if no screening provider is configured (default: false) */
|
|
474
498
|
requireScreening?: boolean;
|
|
475
499
|
}
|
|
500
|
+
/** Wallet monitoring configuration for on-chain event listening */
|
|
501
|
+
interface WalletMonitoringConfig {
|
|
502
|
+
/** Wallet addresses to watch for outgoing stablecoin transfers */
|
|
503
|
+
wallets: string[];
|
|
504
|
+
/** RPC endpoints per chain (required for on-chain listening) */
|
|
505
|
+
rpcEndpoints: Partial<Record<Chain, string>>;
|
|
506
|
+
/** Polling interval in ms for HTTP transports (default: 12000) */
|
|
507
|
+
pollingIntervalMs?: number;
|
|
508
|
+
}
|
|
509
|
+
type WalletProviderType = 'none' | 'circle' | 'coinbase' | 'metamask';
|
|
510
|
+
type WalletProviderConfig = WalletProviderNone | WalletProviderCircle | WalletProviderCoinbase | WalletProviderMetaMask;
|
|
511
|
+
interface WalletProviderNone {
|
|
512
|
+
type: 'none';
|
|
513
|
+
}
|
|
514
|
+
interface WalletProviderCircle {
|
|
515
|
+
type: 'circle';
|
|
516
|
+
apiKeyEnvVar: string;
|
|
517
|
+
entitySecretEnvVar: string;
|
|
518
|
+
circleEnvironment: 'sandbox' | 'production';
|
|
519
|
+
walletSetName?: string;
|
|
520
|
+
secretsStorage: SecretsStorageConfig;
|
|
521
|
+
}
|
|
522
|
+
interface WalletProviderCoinbase {
|
|
523
|
+
type: 'coinbase';
|
|
524
|
+
apiKeyIdEnvVar: string;
|
|
525
|
+
apiKeySecretEnvVar: string;
|
|
526
|
+
walletSecretEnvVar: string;
|
|
527
|
+
cdpEnvironment: 'testnet' | 'mainnet';
|
|
528
|
+
secretsStorage: SecretsStorageConfig;
|
|
529
|
+
}
|
|
530
|
+
interface WalletProviderMetaMask {
|
|
531
|
+
type: 'metamask';
|
|
532
|
+
clientIdEnvVar: string;
|
|
533
|
+
authConnectionId: string;
|
|
534
|
+
web3AuthNetwork: 'sapphire_mainnet' | 'sapphire_devnet';
|
|
535
|
+
secretsStorage: SecretsStorageConfig;
|
|
536
|
+
}
|
|
537
|
+
type SecretsStorageConfig = {
|
|
538
|
+
type: 'dotenv';
|
|
539
|
+
path: string;
|
|
540
|
+
} | {
|
|
541
|
+
type: 'file';
|
|
542
|
+
path: string;
|
|
543
|
+
} | {
|
|
544
|
+
type: 'gcp-secret-manager';
|
|
545
|
+
project: string;
|
|
546
|
+
} | {
|
|
547
|
+
type: 'aws-secrets-manager';
|
|
548
|
+
region: string;
|
|
549
|
+
} | {
|
|
550
|
+
type: 'hashicorp-vault';
|
|
551
|
+
address: string;
|
|
552
|
+
};
|
|
553
|
+
interface CircleWalletConfig {
|
|
554
|
+
apiKey: string;
|
|
555
|
+
entitySecret: string;
|
|
556
|
+
baseUrl?: string;
|
|
557
|
+
}
|
|
558
|
+
interface CreateWalletSetInput {
|
|
559
|
+
name: string;
|
|
560
|
+
idempotencyKey?: string;
|
|
561
|
+
}
|
|
562
|
+
interface CircleWalletSet {
|
|
563
|
+
id: string;
|
|
564
|
+
name: string;
|
|
565
|
+
custodyType: string;
|
|
566
|
+
createDate: string;
|
|
567
|
+
updateDate: string;
|
|
568
|
+
}
|
|
569
|
+
interface CreateWalletInput {
|
|
570
|
+
walletSetId: string;
|
|
571
|
+
blockchains: Chain[];
|
|
572
|
+
count?: number;
|
|
573
|
+
accountType?: 'EOA' | 'SCA';
|
|
574
|
+
idempotencyKey?: string;
|
|
575
|
+
}
|
|
576
|
+
interface CircleWallet {
|
|
577
|
+
id: string;
|
|
578
|
+
state: string;
|
|
579
|
+
address: string;
|
|
580
|
+
blockchain: string;
|
|
581
|
+
walletSetId: string;
|
|
582
|
+
createDate: string;
|
|
583
|
+
}
|
|
584
|
+
interface CircleTransferInput {
|
|
585
|
+
walletId: string;
|
|
586
|
+
tokenAddress: string;
|
|
587
|
+
destinationAddress: string;
|
|
588
|
+
amount: string;
|
|
589
|
+
blockchain: Chain;
|
|
590
|
+
agentId?: string;
|
|
591
|
+
idempotencyKey?: string;
|
|
592
|
+
}
|
|
593
|
+
interface CircleTransferResult {
|
|
594
|
+
id: string;
|
|
595
|
+
state: string;
|
|
596
|
+
txHash?: string;
|
|
597
|
+
complianceResult?: VerifyResult;
|
|
598
|
+
}
|
|
599
|
+
interface CoinbaseWalletConfig {
|
|
600
|
+
apiKeyId: string;
|
|
601
|
+
apiKeySecret: string;
|
|
602
|
+
walletSecret: string;
|
|
603
|
+
}
|
|
604
|
+
interface CoinbaseAccount {
|
|
605
|
+
address: string;
|
|
606
|
+
name?: string;
|
|
607
|
+
network: string;
|
|
608
|
+
}
|
|
609
|
+
interface CoinbaseTransferInput {
|
|
610
|
+
fromAddress: string;
|
|
611
|
+
toAddress: string;
|
|
612
|
+
amount: string;
|
|
613
|
+
token: Token;
|
|
614
|
+
network: string;
|
|
615
|
+
agentId?: string;
|
|
616
|
+
}
|
|
617
|
+
interface CoinbaseTransferResult {
|
|
618
|
+
transactionHash: string;
|
|
619
|
+
status: string;
|
|
620
|
+
complianceResult?: VerifyResult;
|
|
621
|
+
}
|
|
622
|
+
interface MetaMaskWalletConfig {
|
|
623
|
+
clientId: string;
|
|
624
|
+
authConnectionId: string;
|
|
625
|
+
web3AuthNetwork: 'sapphire_mainnet' | 'sapphire_devnet';
|
|
626
|
+
}
|
|
627
|
+
interface MetaMaskAccount {
|
|
628
|
+
address: string;
|
|
629
|
+
publicKey: string;
|
|
630
|
+
}
|
|
631
|
+
interface MetaMaskTransferInput {
|
|
632
|
+
toAddress: string;
|
|
633
|
+
amount: string;
|
|
634
|
+
token: Token;
|
|
635
|
+
chain: Chain;
|
|
636
|
+
agentId?: string;
|
|
637
|
+
idToken: string;
|
|
638
|
+
}
|
|
639
|
+
interface MetaMaskTransferResult {
|
|
640
|
+
transactionHash: string;
|
|
641
|
+
status: string;
|
|
642
|
+
complianceResult?: VerifyResult;
|
|
643
|
+
}
|
|
476
644
|
/**
|
|
477
645
|
* Interface for metadata validation. Compatible with Zod schemas and any
|
|
478
646
|
* validator that implements a `parse` method.
|
|
@@ -1713,6 +1881,45 @@ declare class FeatureFlagManager {
|
|
|
1713
1881
|
private triggerBackgroundRefresh;
|
|
1714
1882
|
}
|
|
1715
1883
|
|
|
1884
|
+
/** Minimal Kontext interface needed by the monitor */
|
|
1885
|
+
interface KontextForMonitor {
|
|
1886
|
+
verify(input: VerifyInput): Promise<VerifyResult>;
|
|
1887
|
+
}
|
|
1888
|
+
/**
|
|
1889
|
+
* Watches monitored wallets on-chain for stablecoin Transfer events.
|
|
1890
|
+
* Uses viem's watchEvent with HTTP polling (works with any RPC endpoint).
|
|
1891
|
+
*/
|
|
1892
|
+
declare class WalletMonitor {
|
|
1893
|
+
private readonly kontext;
|
|
1894
|
+
private readonly config;
|
|
1895
|
+
private readonly agentId;
|
|
1896
|
+
private readonly tokens;
|
|
1897
|
+
private readonly unwatchers;
|
|
1898
|
+
private running;
|
|
1899
|
+
/** Shared dedup set — tracks recently verified txHashes (populated by both layers) */
|
|
1900
|
+
readonly verifiedTxHashes: Set<string>;
|
|
1901
|
+
private cleanupTimer;
|
|
1902
|
+
private readonly txTimestamps;
|
|
1903
|
+
constructor(kontext: KontextForMonitor, config: WalletMonitoringConfig, options?: {
|
|
1904
|
+
agentId?: string;
|
|
1905
|
+
tokens?: Token[];
|
|
1906
|
+
});
|
|
1907
|
+
/**
|
|
1908
|
+
* Mark a txHash as already verified (called by the viem interceptor layer).
|
|
1909
|
+
* The monitor will skip this tx if it later sees it on-chain.
|
|
1910
|
+
*/
|
|
1911
|
+
markVerified(txHash: string): void;
|
|
1912
|
+
/**
|
|
1913
|
+
* Start watching all configured chains for stablecoin transfers.
|
|
1914
|
+
* Dynamically imports viem — requires viem as a peer dependency.
|
|
1915
|
+
*/
|
|
1916
|
+
start(): Promise<void>;
|
|
1917
|
+
/** Stop all watchers and cleanup */
|
|
1918
|
+
stop(): void;
|
|
1919
|
+
isRunning(): boolean;
|
|
1920
|
+
private handleTransferLog;
|
|
1921
|
+
}
|
|
1922
|
+
|
|
1716
1923
|
/** Entity type for an agent identity */
|
|
1717
1924
|
type EntityType = 'individual' | 'organization' | 'bot' | 'unknown';
|
|
1718
1925
|
/** KYC verification status */
|
|
@@ -2337,12 +2544,16 @@ declare class Kontext {
|
|
|
2337
2544
|
private readonly trustScorer;
|
|
2338
2545
|
private readonly anomalyDetector;
|
|
2339
2546
|
private readonly screeningAggregator;
|
|
2547
|
+
private walletMonitor;
|
|
2340
2548
|
private provenanceManager;
|
|
2341
2549
|
private identityRegistry;
|
|
2342
2550
|
private walletClusterer;
|
|
2343
2551
|
private behavioralFingerprinter;
|
|
2344
2552
|
private crossSessionLinker;
|
|
2345
2553
|
private confidenceScorer;
|
|
2554
|
+
private circleWalletManager;
|
|
2555
|
+
private coinbaseWalletManager;
|
|
2556
|
+
private metamaskWalletManager;
|
|
2346
2557
|
private constructor();
|
|
2347
2558
|
/**
|
|
2348
2559
|
* Initialize the Kontext SDK.
|
|
@@ -2373,7 +2584,7 @@ declare class Kontext {
|
|
|
2373
2584
|
* });
|
|
2374
2585
|
* ```
|
|
2375
2586
|
*/
|
|
2376
|
-
static init(config
|
|
2587
|
+
static init(config?: KontextConfig): Kontext;
|
|
2377
2588
|
/**
|
|
2378
2589
|
* Get the current operating mode.
|
|
2379
2590
|
*/
|
|
@@ -2407,6 +2618,12 @@ declare class Kontext {
|
|
|
2407
2618
|
private getCrossSessionLinker;
|
|
2408
2619
|
/** Lazy-init KYAConfidenceScorer on first use. */
|
|
2409
2620
|
private getConfidenceScorer;
|
|
2621
|
+
/** Lazy-init CircleWalletManager from config.walletProvider */
|
|
2622
|
+
private getCircleManager;
|
|
2623
|
+
/** Lazy-init CoinbaseWalletManager from config.walletProvider */
|
|
2624
|
+
private getCoinbaseManager;
|
|
2625
|
+
/** Lazy-init MetaMaskWalletManager from config.walletProvider */
|
|
2626
|
+
private getMetaMaskManager;
|
|
2410
2627
|
/**
|
|
2411
2628
|
* Log a generic agent action.
|
|
2412
2629
|
*
|
|
@@ -2862,14 +3079,38 @@ declare class Kontext {
|
|
|
2862
3079
|
* Get the underlying FeatureFlagManager (or null if not configured).
|
|
2863
3080
|
*/
|
|
2864
3081
|
getFeatureFlagManager(): FeatureFlagManager | null;
|
|
2865
|
-
/**
|
|
2866
|
-
|
|
3082
|
+
/** Create a Circle wallet set. Enterprise plan required. */
|
|
3083
|
+
createCircleWalletSet(input: CreateWalletSetInput): Promise<CircleWalletSet>;
|
|
3084
|
+
/** Create Circle wallet(s) in a wallet set. Enterprise plan required. */
|
|
3085
|
+
createCircleWallet(input: CreateWalletInput): Promise<CircleWallet[]>;
|
|
3086
|
+
/** Transfer via Circle with auto-compliance. Enterprise plan required. */
|
|
3087
|
+
circleTransferWithCompliance(input: CircleTransferInput): Promise<CircleTransferResult>;
|
|
3088
|
+
/** Create a Coinbase CDP account. Enterprise plan required. */
|
|
3089
|
+
createCoinbaseAccount(opts?: {
|
|
3090
|
+
name?: string;
|
|
3091
|
+
network?: string;
|
|
3092
|
+
}): Promise<CoinbaseAccount>;
|
|
3093
|
+
/** List Coinbase CDP accounts. Enterprise plan required. */
|
|
3094
|
+
listCoinbaseAccounts(): Promise<CoinbaseAccount[]>;
|
|
3095
|
+
/** Transfer via Coinbase CDP with auto-compliance. Enterprise plan required. */
|
|
3096
|
+
coinbaseTransferWithCompliance(input: CoinbaseTransferInput): Promise<CoinbaseTransferResult>;
|
|
3097
|
+
/** Connect to MetaMask Embedded Wallet for a user. Enterprise plan required. */
|
|
3098
|
+
metamaskConnect(idToken: string): Promise<MetaMaskAccount>;
|
|
3099
|
+
/** Transfer via MetaMask with auto-compliance. Enterprise plan required. */
|
|
3100
|
+
metamaskTransferWithCompliance(input: MetaMaskTransferInput): Promise<MetaMaskTransferResult>;
|
|
3101
|
+
/**
|
|
3102
|
+
* Get the wallet monitor instance (or null if not configured).
|
|
3103
|
+
* Used by the viem interceptor for dedup registration.
|
|
3104
|
+
*/
|
|
3105
|
+
getWalletMonitor(): WalletMonitor | null;
|
|
3106
|
+
/**
|
|
3107
|
+
* Gracefully shut down the SDK, flushing any pending data and stopping watchers.
|
|
2867
3108
|
*/
|
|
2868
3109
|
destroy(): Promise<void>;
|
|
2869
3110
|
}
|
|
2870
3111
|
|
|
2871
3112
|
/** Features gated by plan tier */
|
|
2872
|
-
type GatedFeature = 'advanced-anomaly-rules' | 'sar-ctr-reports' | 'webhooks' | 'ofac-screening' | 'csv-export' | 'multi-chain' | 'cftc-compliance' | 'circle-wallets' | 'circle-compliance' | 'gas-station' | 'cctp-transfers' | 'approval-policies' | 'unified-screening' | 'blocklist-manager' | 'kya-identity' | 'kya-behavioral';
|
|
3113
|
+
type GatedFeature = 'advanced-anomaly-rules' | 'sar-ctr-reports' | 'webhooks' | 'ofac-screening' | 'csv-export' | 'multi-chain' | 'cftc-compliance' | 'circle-wallets' | 'circle-compliance' | 'gas-station' | 'cctp-transfers' | 'approval-policies' | 'unified-screening' | 'blocklist-manager' | 'kya-identity' | 'kya-behavioral' | 'coinbase-wallets' | 'metamask-wallets';
|
|
2873
3114
|
/**
|
|
2874
3115
|
* Check if a feature is available on the given plan.
|
|
2875
3116
|
* Returns true if allowed, false if not.
|
|
@@ -3854,4 +4095,250 @@ declare class ScreeningAggregator {
|
|
|
3854
4095
|
private buildResult;
|
|
3855
4096
|
}
|
|
3856
4097
|
|
|
3857
|
-
|
|
4098
|
+
/** Minimal WalletClient shape — avoids hard type dependency on viem */
|
|
4099
|
+
interface WalletClientLike {
|
|
4100
|
+
sendTransaction: (args: any) => Promise<`0x${string}`>;
|
|
4101
|
+
writeContract?: (args: any) => Promise<`0x${string}`>;
|
|
4102
|
+
chain?: {
|
|
4103
|
+
id: number;
|
|
4104
|
+
name?: string;
|
|
4105
|
+
};
|
|
4106
|
+
account?: {
|
|
4107
|
+
address: `0x${string}`;
|
|
4108
|
+
};
|
|
4109
|
+
extend: <T>(fn: (client: any) => T) => any;
|
|
4110
|
+
}
|
|
4111
|
+
/** Minimal Kontext interface needed by the interceptor */
|
|
4112
|
+
interface KontextForInterceptor {
|
|
4113
|
+
verify(input: VerifyInput): Promise<VerifyResult>;
|
|
4114
|
+
getConfig(): {
|
|
4115
|
+
agentId?: string;
|
|
4116
|
+
interceptorMode?: string;
|
|
4117
|
+
policy?: {
|
|
4118
|
+
allowedTokens?: Token[];
|
|
4119
|
+
};
|
|
4120
|
+
};
|
|
4121
|
+
getWalletMonitor?(): WalletMonitor | null;
|
|
4122
|
+
}
|
|
4123
|
+
/** Options for the viem auto-instrumentation decorator */
|
|
4124
|
+
interface ViemInstrumentationOptions {
|
|
4125
|
+
/** Agent ID to attribute transactions to */
|
|
4126
|
+
agentId?: string;
|
|
4127
|
+
/** Session ID for grouping transactions */
|
|
4128
|
+
sessionId?: string;
|
|
4129
|
+
/** Tokens to instrument (default: all known) */
|
|
4130
|
+
tokens?: Token[];
|
|
4131
|
+
/** Chains to instrument (default: all known) */
|
|
4132
|
+
chains?: Chain[];
|
|
4133
|
+
/** Compliance mode (default: reads from config, falls back to 'post-send') */
|
|
4134
|
+
mode?: 'post-send' | 'pre-send' | 'both';
|
|
4135
|
+
/** Called after verify() succeeds */
|
|
4136
|
+
onVerify?: (result: VerifyResult, txHash: string) => void | Promise<void>;
|
|
4137
|
+
/** Called when verify() fails */
|
|
4138
|
+
onError?: (error: Error, txHash: string) => void | Promise<void>;
|
|
4139
|
+
/** Additional metadata for every verify() call */
|
|
4140
|
+
metadata?: Record<string, unknown>;
|
|
4141
|
+
}
|
|
4142
|
+
/**
|
|
4143
|
+
* Thrown in pre-send mode when compliance screening fails.
|
|
4144
|
+
*/
|
|
4145
|
+
declare class ViemComplianceError extends Error {
|
|
4146
|
+
readonly result: VerifyResult;
|
|
4147
|
+
readonly from: string;
|
|
4148
|
+
readonly to: string;
|
|
4149
|
+
readonly amount: string;
|
|
4150
|
+
constructor(message: string, result: VerifyResult, details: {
|
|
4151
|
+
from: string;
|
|
4152
|
+
to: string;
|
|
4153
|
+
amount: string;
|
|
4154
|
+
});
|
|
4155
|
+
}
|
|
4156
|
+
/**
|
|
4157
|
+
* Wraps a viem WalletClient with Kontext auto-instrumentation.
|
|
4158
|
+
* Every stablecoin transfer is automatically compliance-checked via verify().
|
|
4159
|
+
*
|
|
4160
|
+
* Reads defaults from kontext.getConfig() — options override config values.
|
|
4161
|
+
*/
|
|
4162
|
+
declare function withKontextCompliance<TClient extends WalletClientLike>(client: TClient, kontext: KontextForInterceptor, options?: Partial<ViemInstrumentationOptions>): TClient;
|
|
4163
|
+
|
|
4164
|
+
interface StablecoinContractInfo {
|
|
4165
|
+
token: Token;
|
|
4166
|
+
chain: Chain;
|
|
4167
|
+
decimals: number;
|
|
4168
|
+
}
|
|
4169
|
+
/**
|
|
4170
|
+
* Known stablecoin contract addresses indexed by lowercased address.
|
|
4171
|
+
* Used for O(1) detection of whether a transaction targets a stablecoin.
|
|
4172
|
+
*/
|
|
4173
|
+
declare const STABLECOIN_CONTRACTS: Record<string, StablecoinContractInfo>;
|
|
4174
|
+
/**
|
|
4175
|
+
* Maps viem chain IDs to Kontext Chain strings.
|
|
4176
|
+
*/
|
|
4177
|
+
declare const CHAIN_ID_MAP: Record<number, Chain>;
|
|
4178
|
+
|
|
4179
|
+
/** Shape of the kontext.config.json file */
|
|
4180
|
+
interface KontextConfigFile {
|
|
4181
|
+
$schema?: string;
|
|
4182
|
+
projectId: string;
|
|
4183
|
+
agentId?: string;
|
|
4184
|
+
environment?: Environment;
|
|
4185
|
+
wallets?: string[];
|
|
4186
|
+
tokens?: Token[];
|
|
4187
|
+
chains?: Chain[];
|
|
4188
|
+
rpcEndpoints?: Partial<Record<Chain, string>>;
|
|
4189
|
+
mode?: 'post-send' | 'pre-send' | 'both';
|
|
4190
|
+
corridors?: {
|
|
4191
|
+
from?: string;
|
|
4192
|
+
to?: string;
|
|
4193
|
+
};
|
|
4194
|
+
thresholds?: {
|
|
4195
|
+
alertAmount?: string;
|
|
4196
|
+
ctrAmount?: string;
|
|
4197
|
+
};
|
|
4198
|
+
apiKey?: string;
|
|
4199
|
+
walletProvider?: WalletProviderConfig;
|
|
4200
|
+
}
|
|
4201
|
+
/**
|
|
4202
|
+
* Discover and load kontext.config.json by walking up from startDir.
|
|
4203
|
+
* Returns the parsed config file contents, or null if not found.
|
|
4204
|
+
*/
|
|
4205
|
+
declare function loadConfigFile(startDir?: string): KontextConfigFile | null;
|
|
4206
|
+
|
|
4207
|
+
/**
|
|
4208
|
+
* CircleWalletManager wraps Circle Programmable Wallets (developer-controlled)
|
|
4209
|
+
* with automatic compliance logging via Kontext.
|
|
4210
|
+
*
|
|
4211
|
+
* Enterprise plan-gated — plan checks enforced at the Kontext client level.
|
|
4212
|
+
*/
|
|
4213
|
+
declare class CircleWalletManager {
|
|
4214
|
+
private readonly apiKey;
|
|
4215
|
+
private readonly entitySecret;
|
|
4216
|
+
private readonly baseUrl;
|
|
4217
|
+
private kontext;
|
|
4218
|
+
constructor(config: CircleWalletConfig);
|
|
4219
|
+
/** Link to Kontext instance for auto-compliance logging */
|
|
4220
|
+
setKontext(kontext: any): void;
|
|
4221
|
+
/** Validate credentials by calling Circle's configuration endpoint */
|
|
4222
|
+
validateCredentials(): Promise<boolean>;
|
|
4223
|
+
/** Create a wallet set (container for wallets) */
|
|
4224
|
+
createWalletSet(input: CreateWalletSetInput): Promise<CircleWalletSet>;
|
|
4225
|
+
/** Create wallet(s) in a wallet set */
|
|
4226
|
+
createWallet(input: CreateWalletInput): Promise<CircleWallet[]>;
|
|
4227
|
+
/** List wallets, optionally filtered by wallet set */
|
|
4228
|
+
listWallets(walletSetId?: string): Promise<CircleWallet[]>;
|
|
4229
|
+
/** Get wallet token balances */
|
|
4230
|
+
getBalance(walletId: string): Promise<{
|
|
4231
|
+
token: string;
|
|
4232
|
+
amount: string;
|
|
4233
|
+
}[]>;
|
|
4234
|
+
/** Transfer with auto-compliance: runs verify() before/after transfer */
|
|
4235
|
+
transferWithCompliance(input: CircleTransferInput): Promise<CircleTransferResult>;
|
|
4236
|
+
private headers;
|
|
4237
|
+
private request;
|
|
4238
|
+
private mapChain;
|
|
4239
|
+
}
|
|
4240
|
+
|
|
4241
|
+
/**
|
|
4242
|
+
* CoinbaseWalletManager wraps Coinbase Developer Platform (CDP) server wallets
|
|
4243
|
+
* with automatic compliance logging via Kontext.
|
|
4244
|
+
*
|
|
4245
|
+
* Enterprise plan-gated — plan checks enforced at the Kontext client level.
|
|
4246
|
+
*
|
|
4247
|
+
* Auth model:
|
|
4248
|
+
* - API requests: JWT Bearer token signed with apiKeySecret (Ed25519), 120s expiry
|
|
4249
|
+
* - Wallet operations: X-Wallet-Auth header (JWT signed with walletSecret, 60s expiry)
|
|
4250
|
+
*/
|
|
4251
|
+
declare class CoinbaseWalletManager {
|
|
4252
|
+
private readonly apiKeyId;
|
|
4253
|
+
private readonly apiKeySecret;
|
|
4254
|
+
private readonly walletSecret;
|
|
4255
|
+
private readonly baseUrl;
|
|
4256
|
+
private kontext;
|
|
4257
|
+
constructor(config: CoinbaseWalletConfig);
|
|
4258
|
+
/** Link to Kontext instance for auto-compliance logging */
|
|
4259
|
+
setKontext(kontext: any): void;
|
|
4260
|
+
/** Validate credentials by listing accounts */
|
|
4261
|
+
validateCredentials(): Promise<boolean>;
|
|
4262
|
+
/** Create an EVM account */
|
|
4263
|
+
createAccount(opts?: {
|
|
4264
|
+
name?: string;
|
|
4265
|
+
network?: string;
|
|
4266
|
+
}): Promise<CoinbaseAccount>;
|
|
4267
|
+
/** List accounts */
|
|
4268
|
+
listAccounts(): Promise<CoinbaseAccount[]>;
|
|
4269
|
+
/** Get token balances for an address */
|
|
4270
|
+
getBalances(address: string, network: string): Promise<{
|
|
4271
|
+
token: string;
|
|
4272
|
+
amount: string;
|
|
4273
|
+
}[]>;
|
|
4274
|
+
/** Transfer with auto-compliance: runs verify() before/after transfer */
|
|
4275
|
+
transferWithCompliance(input: CoinbaseTransferInput): Promise<CoinbaseTransferResult>;
|
|
4276
|
+
/**
|
|
4277
|
+
* Build auth headers. CDP uses JWT Bearer tokens:
|
|
4278
|
+
* - API auth: signed with apiKeySecret, apiKeyId as kid, 120s expiry
|
|
4279
|
+
* - Wallet auth: X-Wallet-Auth header signed with walletSecret, 60s expiry
|
|
4280
|
+
*
|
|
4281
|
+
* Note: Full Ed25519 JWT signing requires the jose or crypto module.
|
|
4282
|
+
* This implementation provides the header structure; production use
|
|
4283
|
+
* should integrate with @coinbase/cdp-sdk for proper JWT signing.
|
|
4284
|
+
*/
|
|
4285
|
+
private headers;
|
|
4286
|
+
/**
|
|
4287
|
+
* Build a minimal JWT structure. In production, this should use Ed25519
|
|
4288
|
+
* signing via the crypto module or jose library. Here we build the
|
|
4289
|
+
* structure that CDP expects.
|
|
4290
|
+
*/
|
|
4291
|
+
private buildJwt;
|
|
4292
|
+
private request;
|
|
4293
|
+
private mapNetwork;
|
|
4294
|
+
}
|
|
4295
|
+
|
|
4296
|
+
/**
|
|
4297
|
+
* MetaMaskWalletManager wraps MetaMask Embedded Wallets (via Web3Auth Node SDK)
|
|
4298
|
+
* with automatic compliance logging via Kontext.
|
|
4299
|
+
*
|
|
4300
|
+
* Enterprise plan-gated — plan checks enforced at the Kontext client level.
|
|
4301
|
+
*
|
|
4302
|
+
* Requirements:
|
|
4303
|
+
* - `@web3auth/node-sdk` must be installed as a peer dependency
|
|
4304
|
+
* - Stateless: each connect() call is independent (no session state)
|
|
4305
|
+
* - Infura RPC access is pre-integrated (no separate key needed)
|
|
4306
|
+
*/
|
|
4307
|
+
declare class MetaMaskWalletManager {
|
|
4308
|
+
private readonly clientId;
|
|
4309
|
+
private readonly authConnectionId;
|
|
4310
|
+
private readonly web3AuthNetwork;
|
|
4311
|
+
private kontext;
|
|
4312
|
+
constructor(config: MetaMaskWalletConfig);
|
|
4313
|
+
/** Link to Kontext instance for auto-compliance logging */
|
|
4314
|
+
setKontext(kontext: any): void;
|
|
4315
|
+
/**
|
|
4316
|
+
* Validate credentials by attempting to initialize Web3Auth.
|
|
4317
|
+
* Returns false if @web3auth/node-sdk is not installed.
|
|
4318
|
+
*/
|
|
4319
|
+
validateCredentials(): Promise<boolean>;
|
|
4320
|
+
/**
|
|
4321
|
+
* Connect and get account for a user.
|
|
4322
|
+
* Requires a JWT idToken for custom auth via authConnectionId.
|
|
4323
|
+
*/
|
|
4324
|
+
connect(idToken: string): Promise<MetaMaskAccount>;
|
|
4325
|
+
/**
|
|
4326
|
+
* Get the private key for an authenticated user.
|
|
4327
|
+
* Use with caution — only for signing transactions server-side.
|
|
4328
|
+
*/
|
|
4329
|
+
getPrivateKey(idToken: string): Promise<string>;
|
|
4330
|
+
/** Transfer with auto-compliance: runs verify() before/after transfer */
|
|
4331
|
+
transferWithCompliance(input: MetaMaskTransferInput): Promise<MetaMaskTransferResult>;
|
|
4332
|
+
/**
|
|
4333
|
+
* Dynamically import @web3auth/node-sdk. Returns null if not installed.
|
|
4334
|
+
*/
|
|
4335
|
+
private loadWeb3Auth;
|
|
4336
|
+
/**
|
|
4337
|
+
* Require @web3auth/node-sdk — throws if not installed.
|
|
4338
|
+
*/
|
|
4339
|
+
private requireWeb3Auth;
|
|
4340
|
+
private getAccounts;
|
|
4341
|
+
private requestPrivateKey;
|
|
4342
|
+
}
|
|
4343
|
+
|
|
4344
|
+
export { type ActionLog, type AgentCard, type AgentData, type AgentIdentity, AgentIdentityRegistry, type AgentLink, type AgentSession, type AggregatedScreeningResult, type AnchorResult, type AnchorVerification, type AnomalyCallback, type AnomalyDetectionConfig, AnomalyDetector, type AnomalyEvent, type AnomalyRuleType, type AnomalySeverity, type AnomalyThresholds, type AttestationDecision, type AttestationPayload, type AttestationRequest, type AttestationResponse, type AttestationSignature, type BehavioralEmbedding, BehavioralFingerprinter, CHAIN_ID_MAP, CURRENCY_REQUIRED_LISTS, type Chain, ChainalysisFreeAPIProvider, ChainalysisOracleProvider, type CheckpointStatus, type CircleTransferInput, type CircleTransferResult, type CircleWallet, type CircleWalletConfig, CircleWalletManager, type CircleWalletSet, type ClusteringEvidence, type ClusteringHeuristic, type CoinbaseAccount, type CoinbaseTransferInput, type CoinbaseTransferResult, type CoinbaseWalletConfig, CoinbaseWalletManager, type ComplianceCertificate, type ComplianceCheckResult, type ComplianceReport, type ConfirmTaskInput, type ConsensusStrategy, ConsoleExporter, type CounterpartyAttestation, type CounterpartyConfig, type CreateCheckpointInput, type CreateSessionInput, type CreateTaskInput, type CreateWalletInput, type CreateWalletSetInput, CrossSessionLinker, type CrossSessionLinkerConfig, type DateRange, DigestChain, type DigestLink, type DigestVerification, type ERC8021Attribution, type ERC8021Config, type EntityStatus, type EntityType, type Environment, type EventExporter, type ExportFormat, type ExportOptions, type ExportResult, type ExporterResult, type FeatureFlag, type FeatureFlagConfig, FeatureFlagManager, FileStorage, type FinancialFeatures, type FlagPlanTargeting, type FlagScope, type FlagTargeting, type GatedFeature, type GenerateComplianceCertificateInput, type HumanAttestation, JsonFileExporter, type Jurisdiction, KONTEXT_BUILDER_CODE, type KYAConfidenceLevel, type KYAConfidenceScore, KYAConfidenceScorer, type KYAConfidenceScorerConfig, type KYAEnvelope, type KYAScoreComponent, type KYCProviderReference, type KYCStatus, Kontext, type KontextConfig, KontextError, KontextErrorCode, type KontextMode, type LimitEvent, type LinkSignal, type LinkStatus, type LogActionInput, type LogLevel, type LogReasoningInput, type LogTransactionInput, type MatchType, MemoryStorage, type MetaMaskAccount, type MetaMaskTransferInput, type MetaMaskTransferResult, type MetaMaskWalletConfig, MetaMaskWalletManager, type MetadataValidator, type NetworkFeatures, NoopExporter, OFACAddressProvider, OFACEntityProvider, type OnChainAnchorConfig, OnChainExporter, OpenSanctionsLocalProvider, OpenSanctionsProvider, type OperationalFeatures, PLAN_LIMITS, PaymentCompliance, type PlanConfig, PlanManager, type PlanTier, type PlanUsage, type PolicyConfig, type PrecisionTimestamp, type ProvenanceAction, type ProvenanceAttestor, type ProvenanceBundle, type ProvenanceBundleVerification, type ProvenanceCheckpoint, ProvenanceManager, type QueryType, type ReasoningEntry, type RegisterIdentityInput, type ReportOptions, type ReportType, type RiskFactor, STABLECOIN_CONTRACTS, type SanctionsCheckResult, type SanctionsList, ScreeningAggregator, type ScreeningAggregatorConfig, type ScreeningConfig, type ScreeningContext, type ScreeningMatch, type ScreeningProvider, type ScreeningResult, type SecretsStorageConfig, type SessionConstraints, type SessionStatus, type StorageAdapter, TOKEN_REQUIRED_LISTS, type Task, type TaskEvidence, type TaskStatus, type TemporalFeatures, type Token, type TransactionEvaluation, type TransactionRecord, type TrustFactor, type TrustScore, TrustScorer, UKOFSIProvider, type UpdateIdentityInput, UsdcCompliance, type UsdcComplianceCheck, type VerificationKey, type VerifyInput, type VerifyResult, ViemComplianceError, type ViemInstrumentationOptions, type WalletClientLike, type WalletCluster, WalletClusterer, type WalletClusteringConfig, type WalletMapping, WalletMonitor, type WalletMonitoringConfig, type WalletProviderCircle, type WalletProviderCoinbase, type WalletProviderConfig, type WalletProviderMetaMask, type WalletProviderNone, type WalletProviderType, anchorDigest, encodeERC8021Suffix, exchangeAttestation, fetchAgentCard, fetchTransactionAttribution, getAnchor, getRequiredLists, isBlockchainAddress, isCryptoTransaction, isFeatureAvailable, loadConfigFile, parseERC8021Suffix, providerSupportsQuery, requirePlan, verifyAnchor, verifyExportedChain, withKontextCompliance };
|