@sip-protocol/sdk 0.4.0 → 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.
@@ -0,0 +1,223 @@
1
+ /**
2
+ * Compliance reporting types
3
+ *
4
+ * Types for audit report generation and transaction disclosure.
5
+ */
6
+
7
+ import type { EncryptedTransaction, ViewingKey } from '@sip-protocol/types'
8
+
9
+ /**
10
+ * Decrypted transaction data for audit reports
11
+ */
12
+ export interface DecryptedTransaction {
13
+ /** Transaction ID */
14
+ id: string
15
+ /** Sender address */
16
+ sender: string
17
+ /** Recipient address */
18
+ recipient: string
19
+ /** Amount (as string to avoid serialization issues) */
20
+ amount: string
21
+ /** Transaction timestamp */
22
+ timestamp: number
23
+ /** Transaction hash (if available) */
24
+ txHash?: string
25
+ /** Additional metadata */
26
+ metadata?: Record<string, unknown>
27
+ }
28
+
29
+ /**
30
+ * Audit report structure
31
+ */
32
+ export interface AuditReport {
33
+ /** Report ID */
34
+ reportId: string
35
+ /** Generation timestamp */
36
+ generatedAt: Date
37
+ /** Report period */
38
+ period: {
39
+ start: Date
40
+ end: Date
41
+ }
42
+ /** Decrypted transactions */
43
+ transactions: DecryptedTransaction[]
44
+ /** Summary statistics */
45
+ summary: {
46
+ /** Total volume (sum of all amounts as bigint) */
47
+ totalVolume: bigint
48
+ /** Number of transactions */
49
+ transactionCount: number
50
+ /** Number of unique counterparties */
51
+ uniqueCounterparties: number
52
+ }
53
+ }
54
+
55
+ /**
56
+ * Parameters for generating an audit report
57
+ */
58
+ export interface GenerateAuditReportParams {
59
+ /** Viewing key for decryption */
60
+ viewingKey: ViewingKey | string
61
+ /** Encrypted transactions to include */
62
+ transactions: EncryptedTransaction[]
63
+ /** Start date (optional) */
64
+ startDate?: Date
65
+ /** End date (optional) */
66
+ endDate?: Date
67
+ /** Report format */
68
+ format: 'json' | 'pdf'
69
+ }
70
+
71
+ /**
72
+ * PDF export options
73
+ */
74
+ export interface PdfExportOptions {
75
+ /** Report title (default: "SIP Protocol Audit Report") */
76
+ title?: string
77
+ /** Organization name */
78
+ organization?: string
79
+ /** Include transaction details (default: true) */
80
+ includeTransactions?: boolean
81
+ /** Maximum transactions to include in detail section (default: 100) */
82
+ maxTransactions?: number
83
+ }
84
+
85
+ /**
86
+ * Jurisdiction codes for regulatory compliance
87
+ */
88
+ export type Jurisdiction = 'US' | 'EU' | 'UK' | 'SG'
89
+
90
+ /**
91
+ * Regulatory export format types
92
+ */
93
+ export type RegulatoryFormat = 'FATF' | 'FINCEN' | 'CSV'
94
+
95
+ /**
96
+ * FATF Travel Rule export format
97
+ * Simplified version of FATF Recommendation 16 (Travel Rule) for cross-border transfers
98
+ */
99
+ export interface FATFExport {
100
+ /** Report metadata */
101
+ reportId: string
102
+ /** Generation timestamp */
103
+ generatedAt: string
104
+ /** Jurisdiction code */
105
+ jurisdiction: Jurisdiction
106
+ /** Transaction records */
107
+ transactions: FATFTransaction[]
108
+ }
109
+
110
+ /**
111
+ * FATF transaction record
112
+ */
113
+ export interface FATFTransaction {
114
+ /** Originator name (optional for privacy) */
115
+ originatorName?: string
116
+ /** Originator account/address */
117
+ originatorAccount: string
118
+ /** Beneficiary name (optional for privacy) */
119
+ beneficiaryName?: string
120
+ /** Beneficiary account/address */
121
+ beneficiaryAccount: string
122
+ /** Transaction amount */
123
+ amount: string
124
+ /** Currency code (e.g., 'USD', 'ETH') */
125
+ currency: string
126
+ /** Transaction reference */
127
+ transactionRef: string
128
+ /** Transaction timestamp (ISO 8601) */
129
+ timestamp: string
130
+ }
131
+
132
+ /**
133
+ * FINCEN Suspicious Activity Report export format
134
+ * Simplified version of FinCEN SAR (Form 111) for suspicious activity reporting
135
+ */
136
+ export interface FINCENExport {
137
+ /** Report metadata */
138
+ reportId: string
139
+ /** Filing type (always 'SAR' for Suspicious Activity Report) */
140
+ filingType: 'SAR'
141
+ /** Report generation date (ISO 8601) */
142
+ reportDate: string
143
+ /** Jurisdiction (must be 'US') */
144
+ jurisdiction: 'US'
145
+ /** Suspicious activity summary */
146
+ summary: {
147
+ /** Total transaction count */
148
+ transactionCount: number
149
+ /** Total volume */
150
+ totalAmount: string
151
+ /** Date range */
152
+ period: {
153
+ start: string
154
+ end: string
155
+ }
156
+ }
157
+ /** Transaction records */
158
+ transactions: FINCENTransaction[]
159
+ }
160
+
161
+ /**
162
+ * FINCEN transaction record
163
+ */
164
+ export interface FINCENTransaction {
165
+ /** Transaction date (ISO 8601) */
166
+ transactionDate: string
167
+ /** Transaction amount */
168
+ amount: string
169
+ /** Currency code */
170
+ currency: string
171
+ /** Suspicious activity indicators (optional) */
172
+ suspiciousActivity?: string[]
173
+ /** Narrative summary of transaction */
174
+ narrativeSummary: string
175
+ /** Transaction reference */
176
+ transactionRef: string
177
+ /** Involved parties */
178
+ parties: {
179
+ sender: string
180
+ recipient: string
181
+ }
182
+ }
183
+
184
+ /**
185
+ * CSV export format (generic)
186
+ */
187
+ export interface CSVExport {
188
+ /** Report metadata */
189
+ reportId: string
190
+ /** Generation timestamp */
191
+ generatedAt: string
192
+ /** Jurisdiction code */
193
+ jurisdiction: Jurisdiction
194
+ /** CSV headers */
195
+ headers: string[]
196
+ /** CSV rows (array of arrays) */
197
+ rows: string[][]
198
+ }
199
+
200
+ /**
201
+ * Parameters for exporting to regulatory formats
202
+ */
203
+ export interface ExportForRegulatorParams {
204
+ /** Viewing key for decryption */
205
+ viewingKey: ViewingKey | string
206
+ /** Encrypted transactions to include */
207
+ transactions: EncryptedTransaction[]
208
+ /** Target jurisdiction */
209
+ jurisdiction: Jurisdiction
210
+ /** Export format */
211
+ format: RegulatoryFormat
212
+ /** Start date (optional) */
213
+ startDate?: Date
214
+ /** End date (optional) */
215
+ endDate?: Date
216
+ /** Currency code (default: 'USD') */
217
+ currency?: string
218
+ }
219
+
220
+ /**
221
+ * Union type for all regulatory export formats
222
+ */
223
+ export type RegulatoryExport = FATFExport | FINCENExport | CSVExport
package/src/errors.ts CHANGED
@@ -41,6 +41,14 @@ export enum ErrorCode {
41
41
  SIGNATURE_FAILED = 'SIP_3005',
42
42
  INVALID_CURVE_POINT = 'SIP_3006',
43
43
  INVALID_SCALAR = 'SIP_3007',
44
+ INVALID_KEY_SIZE = 'SIP_3008',
45
+ INVALID_ENCRYPTED_DATA = 'SIP_3009',
46
+ INVALID_COMMITMENT = 'SIP_3010',
47
+ INVALID_TIME_LOCK = 'SIP_3011',
48
+ INVALID_SHARE = 'SIP_3012',
49
+ INVALID_THRESHOLD = 'SIP_3013',
50
+ CRYPTO_OPERATION_FAILED = 'SIP_3014',
51
+ INVALID_FORMAT = 'SIP_3015',
44
52
 
45
53
  // Proof errors (4xxx)
46
54
  PROOF_FAILED = 'SIP_4000',
package/src/index.ts CHANGED
@@ -536,7 +536,35 @@ export type { CreatePaymentOptions, StablecoinInfo } from './payment'
536
536
  export { Treasury } from './treasury'
537
537
 
538
538
  // Enterprise Compliance
539
- export { ComplianceManager } from './compliance'
539
+ export {
540
+ ComplianceManager,
541
+ ComplianceReporter,
542
+ generatePdfReport,
543
+ ConditionalDisclosure,
544
+ AuditorKeyDerivation,
545
+ AuditorType,
546
+ ThresholdViewingKey,
547
+ type GenerateAuditReportParams,
548
+ type AuditReport,
549
+ type DecryptedTransaction,
550
+ type PdfExportOptions,
551
+ type ExportForRegulatorParams,
552
+ type RegulatoryExport,
553
+ type RegulatoryFormat,
554
+ type Jurisdiction,
555
+ type FATFExport,
556
+ type FATFTransaction,
557
+ type FINCENExport,
558
+ type FINCENTransaction,
559
+ type CSVExport,
560
+ type DerivedViewingKey,
561
+ type DeriveViewingKeyParams,
562
+ type DeriveMultipleParams,
563
+ type ThresholdShares,
564
+ type TimeLockResult,
565
+ type UnlockResult,
566
+ type TimeLockParams,
567
+ } from './compliance'
540
568
 
541
569
  // Wallet Adapters
542
570
  export {