@profullstack/coinpay 0.4.15 → 0.5.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@profullstack/coinpay",
3
- "version": "0.4.15",
3
+ "version": "0.5.0",
4
4
  "description": "CoinPay SDK & CLI — Accept cryptocurrency payments (BTC, ETH, SOL, POL, BCH, USDC) with wallet and swap support",
5
5
  "type": "module",
6
6
  "main": "./src/index.js",
package/src/index.d.ts CHANGED
@@ -96,5 +96,21 @@ export type {
96
96
  SwapHistoryResult,
97
97
  } from './swap.js';
98
98
 
99
+ // Reputation exports
100
+ export {
101
+ submitReceipt,
102
+ getReputation,
103
+ getCredential,
104
+ verifyCredential,
105
+ getRevocationList,
106
+ } from './reputation.js';
107
+ export type {
108
+ TaskReceipt,
109
+ ReputationSummary,
110
+ MultiWindowReputation,
111
+ CredentialVerification,
112
+ RevocationList,
113
+ } from './reputation.js';
114
+
99
115
  import { CoinPayClient } from './client.js';
100
116
  export default CoinPayClient;
package/src/index.js CHANGED
@@ -78,6 +78,14 @@ import {
78
78
  } from './wallet.js';
79
79
 
80
80
  // Swap exports
81
+ import {
82
+ submitReceipt,
83
+ getReputation,
84
+ getCredential,
85
+ verifyCredential,
86
+ getRevocationList,
87
+ } from './reputation.js';
88
+
81
89
  import {
82
90
  SwapClient,
83
91
  SwapCoins,
@@ -134,6 +142,13 @@ export {
134
142
  PaymentStatus,
135
143
  FiatCurrency,
136
144
 
145
+ // Reputation
146
+ submitReceipt,
147
+ getReputation,
148
+ getCredential,
149
+ verifyCredential,
150
+ getRevocationList,
151
+
137
152
  // Webhook utilities
138
153
  verifyWebhookSignature,
139
154
  generateWebhookSignature,
@@ -0,0 +1,69 @@
1
+ import { CoinPayClient } from './client';
2
+
3
+ export interface TaskReceipt {
4
+ receipt_id: string;
5
+ task_id: string;
6
+ agent_did: string;
7
+ buyer_did: string;
8
+ platform_did: string;
9
+ escrow_tx?: string;
10
+ amount: number;
11
+ currency: string;
12
+ category?: string;
13
+ sla?: Record<string, unknown>;
14
+ outcome: 'completed' | 'failed' | 'disputed' | 'cancelled';
15
+ dispute?: boolean;
16
+ artifact_hash?: string;
17
+ signatures: {
18
+ agent?: string;
19
+ buyer?: string;
20
+ platform?: string;
21
+ };
22
+ finalized_at?: string;
23
+ }
24
+
25
+ export interface ReputationSummary {
26
+ agent_did: string;
27
+ total_tasks: number;
28
+ completed: number;
29
+ failed: number;
30
+ disputed: number;
31
+ cancelled: number;
32
+ completion_rate: number;
33
+ dispute_rate: number;
34
+ total_volume: number;
35
+ avg_task_value: number;
36
+ unique_buyers: number;
37
+ categories: Record<string, { count: number; volume: number }>;
38
+ anti_gaming: {
39
+ circular_payment: boolean;
40
+ burst_detected: boolean;
41
+ below_economic_threshold: boolean;
42
+ insufficient_unique_buyers: boolean;
43
+ flagged: boolean;
44
+ details: string[];
45
+ };
46
+ }
47
+
48
+ export interface MultiWindowReputation {
49
+ '30d': ReputationSummary;
50
+ '90d': ReputationSummary;
51
+ all: ReputationSummary;
52
+ }
53
+
54
+ export interface CredentialVerification {
55
+ valid: boolean;
56
+ reason: string;
57
+ credential?: Record<string, unknown>;
58
+ }
59
+
60
+ export interface RevocationList {
61
+ revoked: string[];
62
+ details: Array<{ credential_id: string; reason: string; revoked_at: string }>;
63
+ }
64
+
65
+ export function submitReceipt(client: CoinPayClient, receipt: TaskReceipt): Promise<{ id: string; verified_signatures: string[] }>;
66
+ export function getReputation(client: CoinPayClient, agentDid: string): Promise<MultiWindowReputation>;
67
+ export function getCredential(client: CoinPayClient, credentialId: string): Promise<Record<string, unknown>>;
68
+ export function verifyCredential(client: CoinPayClient, credentialId: string): Promise<CredentialVerification>;
69
+ export function getRevocationList(client: CoinPayClient): Promise<RevocationList>;
@@ -0,0 +1,51 @@
1
+ /**
2
+ * Reputation SDK Module
3
+ *
4
+ * Submit receipts, query reputation, verify credentials.
5
+ *
6
+ * @example
7
+ * import { CoinPayClient } from '@profullstack/coinpay';
8
+ * const client = new CoinPayClient({ apiKey: 'your-key' });
9
+ *
10
+ * // Submit a task receipt
11
+ * const result = await client.submitReceipt({ ... });
12
+ *
13
+ * // Get agent reputation
14
+ * const rep = await client.getReputation('did:web:agent.example.com');
15
+ */
16
+
17
+ /**
18
+ * Submit a task receipt
19
+ */
20
+ export async function submitReceipt(client, receipt) {
21
+ return client._request('POST', '/api/reputation/receipt', receipt);
22
+ }
23
+
24
+ /**
25
+ * Get aggregated reputation for an agent DID
26
+ */
27
+ export async function getReputation(client, agentDid) {
28
+ const encoded = encodeURIComponent(agentDid);
29
+ return client._request('GET', `/api/reputation/agent/${encoded}/reputation`);
30
+ }
31
+
32
+ /**
33
+ * Get a specific credential by ID
34
+ */
35
+ export async function getCredential(client, credentialId) {
36
+ return client._request('GET', `/api/reputation/credential/${credentialId}`);
37
+ }
38
+
39
+ /**
40
+ * Verify a credential
41
+ */
42
+ export async function verifyCredential(client, credentialId) {
43
+ return client._request('POST', '/api/reputation/verify', { credential_id: credentialId });
44
+ }
45
+
46
+ /**
47
+ * Get the revocation list
48
+ */
49
+ export async function getRevocationList(client) {
50
+ return client._request('GET', '/api/reputation/revocation-list');
51
+ }