@treza/react 0.0.6 → 1.1.2
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 +198 -0
- package/package.json +2 -3
package/README.md
ADDED
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
# @treza/react
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@treza/react)
|
|
4
|
+
[](https://opensource.org/licenses/MIT)
|
|
5
|
+
[](https://www.typescriptlang.org/)
|
|
6
|
+
|
|
7
|
+
React components and hooks for the **Treza Platform** - privacy-preserving KYC verification and compliance UI.
|
|
8
|
+
|
|
9
|
+
## Features
|
|
10
|
+
|
|
11
|
+
- **Pre-built Components** - Ready-to-use KYC verification and compliance UI
|
|
12
|
+
- **React Hooks** - Easily integrate compliance checks into your app
|
|
13
|
+
- **TypeScript** - Full type safety and IntelliSense
|
|
14
|
+
- **Customizable** - Style components to match your design system
|
|
15
|
+
- **Wallet Integration** - Works with popular wallet providers
|
|
16
|
+
|
|
17
|
+
## Installation
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
npm install @treza/react @treza/sdk ethers react react-dom
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Quick Start
|
|
24
|
+
|
|
25
|
+
### ComplianceProvider
|
|
26
|
+
|
|
27
|
+
Wrap your app with the `ComplianceProvider`:
|
|
28
|
+
|
|
29
|
+
```tsx
|
|
30
|
+
import { ComplianceProvider } from '@treza/react';
|
|
31
|
+
|
|
32
|
+
function App() {
|
|
33
|
+
return (
|
|
34
|
+
<ComplianceProvider
|
|
35
|
+
config={{
|
|
36
|
+
apiUrl: 'https://api.trezalabs.com/api',
|
|
37
|
+
contractAddress: '0xB1D98F688Fac29471D91234d9f8EbB37238Df6FA',
|
|
38
|
+
}}
|
|
39
|
+
>
|
|
40
|
+
<YourApp />
|
|
41
|
+
</ComplianceProvider>
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### useCompliance Hook
|
|
47
|
+
|
|
48
|
+
```tsx
|
|
49
|
+
import { useCompliance } from '@treza/react';
|
|
50
|
+
|
|
51
|
+
function VerificationStatus() {
|
|
52
|
+
const {
|
|
53
|
+
isVerified,
|
|
54
|
+
isLoading,
|
|
55
|
+
verifyUser,
|
|
56
|
+
claims
|
|
57
|
+
} = useCompliance();
|
|
58
|
+
|
|
59
|
+
if (isLoading) return <div>Checking verification...</div>;
|
|
60
|
+
|
|
61
|
+
if (!isVerified) {
|
|
62
|
+
return (
|
|
63
|
+
<button onClick={() => verifyUser()}>
|
|
64
|
+
Verify Identity
|
|
65
|
+
</button>
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
return (
|
|
70
|
+
<div>
|
|
71
|
+
<p>✓ Verified</p>
|
|
72
|
+
<p>Country: {claims?.nationality}</p>
|
|
73
|
+
</div>
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### KYCVerificationBadge
|
|
79
|
+
|
|
80
|
+
Display verification status:
|
|
81
|
+
|
|
82
|
+
```tsx
|
|
83
|
+
import { KYCVerificationBadge } from '@treza/react';
|
|
84
|
+
|
|
85
|
+
function UserProfile({ address }) {
|
|
86
|
+
return (
|
|
87
|
+
<div>
|
|
88
|
+
<h2>User Profile</h2>
|
|
89
|
+
<KYCVerificationBadge
|
|
90
|
+
address={address}
|
|
91
|
+
showDetails={true}
|
|
92
|
+
/>
|
|
93
|
+
</div>
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
### ComplianceGate
|
|
99
|
+
|
|
100
|
+
Restrict access based on compliance:
|
|
101
|
+
|
|
102
|
+
```tsx
|
|
103
|
+
import { ComplianceGate } from '@treza/react';
|
|
104
|
+
|
|
105
|
+
function ProtectedContent() {
|
|
106
|
+
return (
|
|
107
|
+
<ComplianceGate
|
|
108
|
+
requirements={{
|
|
109
|
+
mustBeAdult: true,
|
|
110
|
+
allowedCountries: ['US', 'CA', 'GB'],
|
|
111
|
+
}}
|
|
112
|
+
fallback={<VerifyPrompt />}
|
|
113
|
+
>
|
|
114
|
+
<RestrictedContent />
|
|
115
|
+
</ComplianceGate>
|
|
116
|
+
);
|
|
117
|
+
}
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
## Components
|
|
121
|
+
|
|
122
|
+
| Component | Description |
|
|
123
|
+
|-----------|-------------|
|
|
124
|
+
| `ComplianceProvider` | Context provider for compliance state |
|
|
125
|
+
| `KYCVerificationBadge` | Shows verification status |
|
|
126
|
+
| `ComplianceGate` | Conditionally render based on compliance |
|
|
127
|
+
| `VerifyButton` | One-click verification flow |
|
|
128
|
+
| `ClaimsDisplay` | Show verified claims |
|
|
129
|
+
|
|
130
|
+
## Hooks
|
|
131
|
+
|
|
132
|
+
| Hook | Description |
|
|
133
|
+
|------|-------------|
|
|
134
|
+
| `useCompliance` | Main compliance hook |
|
|
135
|
+
| `useKYCStatus` | Check KYC verification status |
|
|
136
|
+
| `useClaims` | Access verified claims |
|
|
137
|
+
| `useComplianceCheck` | Run compliance checks |
|
|
138
|
+
|
|
139
|
+
## Services
|
|
140
|
+
|
|
141
|
+
### WalletService
|
|
142
|
+
|
|
143
|
+
Handle wallet connections and signing:
|
|
144
|
+
|
|
145
|
+
```tsx
|
|
146
|
+
import { WalletService } from '@treza/react';
|
|
147
|
+
|
|
148
|
+
const walletService = new WalletService();
|
|
149
|
+
|
|
150
|
+
// Connect wallet
|
|
151
|
+
const address = await walletService.connect();
|
|
152
|
+
|
|
153
|
+
// Sign message for verification
|
|
154
|
+
const signature = await walletService.signMessage('Verify KYC');
|
|
155
|
+
|
|
156
|
+
// Get network info
|
|
157
|
+
const network = await walletService.getNetwork();
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
### ComplianceService
|
|
161
|
+
|
|
162
|
+
Direct compliance operations:
|
|
163
|
+
|
|
164
|
+
```tsx
|
|
165
|
+
import { ComplianceService } from '@treza/react';
|
|
166
|
+
|
|
167
|
+
const compliance = new ComplianceService({
|
|
168
|
+
apiUrl: 'https://api.trezalabs.com/api',
|
|
169
|
+
contractAddress: '0x...'
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
// Check requirements
|
|
173
|
+
const result = await compliance.checkRequirements(address, {
|
|
174
|
+
mustBeAdult: true,
|
|
175
|
+
allowedCountries: ['US']
|
|
176
|
+
});
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
## Environment Variables
|
|
180
|
+
|
|
181
|
+
```bash
|
|
182
|
+
NEXT_PUBLIC_TREZA_API_URL=https://api.trezalabs.com/api
|
|
183
|
+
NEXT_PUBLIC_KYC_CONTRACT_ADDRESS=0xB1D98F688Fac29471D91234d9f8EbB37238Df6FA
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
## Related Packages
|
|
187
|
+
|
|
188
|
+
- **[@treza/sdk](https://www.npmjs.com/package/@treza/sdk)** - Core SDK (required peer dependency)
|
|
189
|
+
|
|
190
|
+
## Links
|
|
191
|
+
|
|
192
|
+
- **Website**: [trezalabs.com](https://trezalabs.com)
|
|
193
|
+
- **Documentation**: [docs.trezalabs.com](https://docs.trezalabs.com)
|
|
194
|
+
- **GitHub**: [github.com/treza-labs/treza-sdk](https://github.com/treza-labs/treza-sdk)
|
|
195
|
+
|
|
196
|
+
## License
|
|
197
|
+
|
|
198
|
+
MIT
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@treza/react",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "1.1.2",
|
|
4
4
|
"description": "React components for TREZA SDK - Privacy-first DeFi UI components",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"treza",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"typecheck": "tsc --noEmit"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@treza/sdk": "^
|
|
43
|
+
"@treza/sdk": "^1.1.2"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"@rollup/plugin-commonjs": "^25.0.7",
|
|
@@ -71,4 +71,3 @@
|
|
|
71
71
|
"access": "public"
|
|
72
72
|
}
|
|
73
73
|
}
|
|
74
|
-
|