-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.d.ts
More file actions
160 lines (145 loc) · 4.31 KB
/
index.d.ts
File metadata and controls
160 lines (145 loc) · 4.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
/**
* Observer Protocol SDK TypeScript Definitions
* @observerprotocol/sdk v1.0.0
*/
declare module '@observerprotocol/sdk' {
export interface ObserverProtocolOptions {
/** API endpoint URL. Default: https://api.observerprotocol.org */
apiUrl?: string;
/** API key for higher rate limits */
apiKey?: string;
}
export interface AgentRegistrationData {
/** Agent's public key (hex string) */
publicKey: string;
/** Human-readable agent name */
alias: string;
/** Lightning node pubkey (optional) */
lightningNodePubkey?: string;
/** Framework used (optional) */
framework?: string;
/** Capability tags (optional) */
capabilityTags?: string[];
}
export interface RegisteredAgent {
/** Unique agent ID (hashed public key) */
id: string;
/** URL to SVG badge */
badge_url: string;
/** Hash of the public key */
public_key_hash: string;
/** Registration timestamp */
created_at: string;
}
export interface VerificationResult {
/** Whether verification succeeded */
verified: boolean;
/** Verification timestamp */
timestamp: string;
}
export interface TransactionData {
/** Sender agent ID */
senderId: string;
/** Recipient agent ID */
recipientId: string;
/** Amount in satoshis */
amountSats: number;
/** Lightning payment hash */
paymentHash: string;
/** Cryptographic proof (preimage or signature) */
proof: string;
/** Optional context tag */
contextTag?: string;
/** Direction hint (inbound/outbound) */
direction?: 'inbound' | 'outbound';
}
export interface RecordedTransaction {
/** Transaction ID */
id: string;
/** Status of recording */
status: string;
/** Recording timestamp */
recorded_at: string;
}
export interface ReputationData {
/** Total number of verified transactions */
transaction_count: number;
/** Success rate as percentage (0-100) */
success_rate: number;
/** Reputation score (0-100) */
score: number;
/** Badge level (bronze/silver/gold/platinum) */
badge_level: 'bronze' | 'silver' | 'gold' | 'platinum';
/** First transaction timestamp */
first_transaction_at?: string;
/** Last transaction timestamp */
last_transaction_at?: string;
}
export interface TransactionFilters {
/** Filter by agent ID */
agentId?: string;
/** Filter by ISO date (transactions since) */
since?: string;
/** Maximum results to return */
limit?: number;
}
export interface Transaction {
/** Transaction ID */
id: string;
/** Sender agent ID */
sender_id: string;
/** Recipient agent ID */
recipient_id: string;
/** Amount in satoshis */
amount_sats: number;
/** Protocol used (L402, x402, etc.) */
protocol: string;
/** Timestamp bucket */
time_window: string;
/** Verification status */
verified: boolean;
}
export class ObserverProtocol {
/**
* Create a new Observer Protocol SDK instance
* @param options - Configuration options
*/
constructor(options?: ObserverProtocolOptions);
/**
* Register a new agent identity
* @param agentData - Agent registration data
* @returns Registered agent information
*/
registerAgent(agentData: AgentRegistrationData): Promise<RegisteredAgent>;
/**
* Verify agent identity cryptographically
* @param agentId - Agent ID from registration
* @param challengeMessage - Message to sign for verification
* @param signature - Cryptographic signature
* @returns Verification result
*/
verifyAgent(
agentId: string,
challengeMessage: string,
signature: string
): Promise<VerificationResult>;
/**
* Record a verified transaction
* @param transaction - Transaction data
* @returns Recorded transaction information
*/
recordTransaction(transaction: TransactionData): Promise<RecordedTransaction>;
/**
* Get agent reputation data
* @param agentId - Agent ID
* @returns Reputation metrics
*/
getReputation(agentId: string): Promise<ReputationData>;
/**
* Query transaction history
* @param filters - Query filters
* @returns List of transactions
*/
queryTransactions(filters?: TransactionFilters): Promise<Transaction[]>;
}
}