epistery 1.0.0 → 1.0.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.
Files changed (57) hide show
  1. package/README.md +278 -17
  2. package/artifacts/build-info/a865e3b7d26a6bc58fb7aa9022317dd8.json +1 -0
  3. package/artifacts/contracts/agent.sol/Agent.dbg.json +4 -0
  4. package/artifacts/contracts/agent.sol/Agent.json +213 -0
  5. package/dist/api.d.ts +2 -0
  6. package/dist/api.d.ts.map +1 -0
  7. package/dist/api.js +130 -0
  8. package/dist/api.js.map +1 -0
  9. package/dist/controllers/baseController.d.ts +8 -0
  10. package/dist/controllers/baseController.d.ts.map +1 -0
  11. package/dist/controllers/baseController.js +25 -0
  12. package/dist/controllers/baseController.js.map +1 -0
  13. package/dist/controllers/create/CreateController.d.ts +6 -0
  14. package/dist/controllers/create/CreateController.d.ts.map +1 -0
  15. package/dist/controllers/create/CreateController.js +17 -0
  16. package/dist/controllers/create/CreateController.js.map +1 -0
  17. package/dist/controllers/ssl/SSLController.d.ts +17 -0
  18. package/dist/controllers/ssl/SSLController.d.ts.map +1 -0
  19. package/dist/controllers/ssl/SSLController.js +129 -0
  20. package/dist/controllers/ssl/SSLController.js.map +1 -0
  21. package/dist/controllers/status/StatusController.d.ts +6 -0
  22. package/dist/controllers/status/StatusController.d.ts.map +1 -0
  23. package/dist/controllers/status/StatusController.js +29 -0
  24. package/dist/controllers/status/StatusController.js.map +1 -0
  25. package/dist/controllers/write/WriteController.d.ts +7 -0
  26. package/dist/controllers/write/WriteController.d.ts.map +1 -0
  27. package/dist/controllers/write/WriteController.js +50 -0
  28. package/dist/controllers/write/WriteController.js.map +1 -0
  29. package/dist/epistery.d.ts +20 -0
  30. package/dist/epistery.d.ts.map +1 -0
  31. package/dist/epistery.js +235 -0
  32. package/dist/epistery.js.map +1 -0
  33. package/dist/utils/Aqua.d.ts +8 -0
  34. package/dist/utils/Aqua.d.ts.map +1 -0
  35. package/dist/utils/Aqua.js +162 -0
  36. package/dist/utils/Aqua.js.map +1 -0
  37. package/dist/utils/CliWallet.d.ts +116 -0
  38. package/dist/utils/CliWallet.d.ts.map +1 -0
  39. package/dist/utils/CliWallet.js +254 -0
  40. package/dist/utils/CliWallet.js.map +1 -0
  41. package/dist/utils/Config.d.ts +69 -0
  42. package/dist/utils/Config.d.ts.map +1 -0
  43. package/dist/utils/Config.js +178 -0
  44. package/dist/utils/Config.js.map +1 -0
  45. package/dist/utils/Utils.d.ts +22 -0
  46. package/dist/utils/Utils.d.ts.map +1 -0
  47. package/dist/utils/Utils.js +483 -0
  48. package/dist/utils/Utils.js.map +1 -0
  49. package/dist/utils/index.d.ts +5 -0
  50. package/dist/utils/index.d.ts.map +1 -0
  51. package/dist/utils/index.js +25 -0
  52. package/dist/utils/index.js.map +1 -0
  53. package/dist/utils/types.d.ts +101 -0
  54. package/dist/utils/types.d.ts.map +1 -0
  55. package/dist/utils/types.js +3 -0
  56. package/dist/utils/types.js.map +1 -0
  57. package/package.json +1 -1
package/README.md CHANGED
@@ -1,30 +1,37 @@
1
1
  # Epistery
2
2
 
3
- _Epistemology is the study of knowledge. An Epistery, it follows, is a place share the knowledge of knowledge._
3
+ _Epistemology is the study of knowledge. An Epistery, it follows, is a place to share the knowledge of knowledge._
4
4
 
5
- This project is open source middleware that provides websites and browsers a shared neutral space to identify and
6
- verify the origin of data and conduct digital business. It inserts the blockchain as a witness and clerk for the mundane
7
- business of clicking, tipping, stamping and cloaking, currently run by commercial web gatekeepers.
5
+ **Epistery** is blockchain-based middleware that provides websites and applications with decentralized authentication, data ownership verification, and trusted data exchange. It serves as a neutral foundation for web applications to identify users, verify data provenance, and conduct digital business without relying on centralized gatekeepers.
8
6
 
9
- Epistery provides the primitive tools for creating and rendering data-wallets.
7
+ ## What Does Epistery Do?
10
8
 
11
- * /.well-known/epistery - json data presenting the signing identity/wallet of the site
12
- * /.well-known/epistery/status - human version of the above, plus overview of the site's activity and interactive features like comments, ratings.
13
- * /.well-known/epistery/data/* - data-wallet module api for mint, manipulate, render and delete
14
- * /.well-known/acme - Ephemeral ACME url for authorizing ssl cert assignment.
9
+ Epistery adds blockchain-backed identity and data wallet capabilities to any Express.js application through a simple plugin architecture. It provides:
15
10
 
16
- ## Usage
11
+ - **Decentralized Authentication**: Wallet-based user authentication with automatic key exchange
12
+ - **Data Wallets**: Blockchain-anchored data ownership and provenance tracking
13
+ - **Whitelist Management**: On-chain access control for domains and users
14
+ - **CLI Tools**: Command-line interface for authenticated API requests
15
+ - **Client Libraries**: Browser-based wallet and authentication tools
16
+
17
+ ## Quick Start
18
+
19
+ ### Installation
17
20
 
18
21
  ```bash
19
22
  npm install epistery
20
23
  ```
21
24
 
22
- Initialize your domain:
25
+ ### Server Setup
26
+
27
+ Initialize a domain to create its blockchain wallet:
28
+
23
29
  ```bash
24
30
  npx epistery initialize mydomain.com
25
31
  ```
26
32
 
27
- In your Express application:
33
+ Integrate Epistery into your Express application:
34
+
28
35
  ```javascript
29
36
  import express from 'express';
30
37
  import https from 'https';
@@ -37,14 +44,268 @@ const epistery = await Epistery.connect();
37
44
  await epistery.setDomain('mydomain.com');
38
45
  await epistery.attach(app);
39
46
 
47
+ // Optional: Add authentication callback
48
+ const episteryWithAuth = await Epistery.connect({
49
+ authentication: async (clientInfo) => {
50
+ // clientInfo.address contains the wallet address
51
+ // Return user profile or null
52
+ return await getUserProfile(clientInfo.address);
53
+ },
54
+ onAuthenticated: async (clientInfo, req, res) => {
55
+ // Called after successful authentication
56
+ console.log('User authenticated:', clientInfo.address);
57
+ }
58
+ });
59
+
40
60
  // Start your server
41
61
  const https_server = https.createServer(epistery.config.SNI, app);
42
62
  https_server.listen(443);
43
63
  ```
44
64
 
45
- ## Data Wallets
65
+ This automatically mounts RFC 8615-compliant routes under `/.well-known/epistery/`:
66
+ - `/.well-known/epistery` - Server wallet status (JSON)
67
+ - `/.well-known/epistery/status` - Human-readable status page
68
+ - `/.well-known/epistery/connect` - Client key exchange endpoint
69
+ - `/.well-known/epistery/data/*` - Data wallet operations
70
+ - `/.well-known/epistery/whitelist` - Access control endpoints
71
+
72
+ ## Core Features
73
+
74
+ ### 1. Authentication
75
+
76
+ Epistery provides cryptographic authentication using Ethereum wallets:
77
+
78
+ **Client-side:**
79
+ ```javascript
80
+ // Load client library in your HTML
81
+ <script src="/.well-known/epistery/lib/client.js"></script>
82
+ <script>
83
+ const client = new EpisteryClient();
84
+ await client.connect(); // Automatic key exchange
85
+ console.log('Connected as:', client.address);
86
+ </script>
87
+ ```
88
+
89
+ **Server-side:**
90
+ ```javascript
91
+ // Access authenticated client in routes
92
+ app.get('/profile', (req, res) => {
93
+ if (req.episteryClient?.authenticated) {
94
+ res.json({ address: req.episteryClient.address });
95
+ } else {
96
+ res.status(401).json({ error: 'Not authenticated' });
97
+ }
98
+ });
99
+ ```
100
+
101
+ ### 2. Data Wallets
102
+
103
+ Data wallets attach blockchain-based ownership and provenance to any data:
104
+
105
+ ```javascript
106
+ // Client creates data wallet
107
+ const dataWallet = await client.write({
108
+ title: 'My Document',
109
+ content: 'Document content...',
110
+ metadata: { tags: ['important'] }
111
+ });
112
+
113
+ // Read data wallet
114
+ const data = await client.read();
115
+
116
+ // Transfer ownership
117
+ await client.transferOwnership(newOwnerAddress);
118
+ ```
119
+
120
+ Data wallets use IPFS for storage by default, with only hashes and ownership records stored on-chain.
121
+
122
+ ### 3. Whitelist Management
123
+
124
+ Control who can access your domain using on-chain whitelists:
125
+
126
+ ```javascript
127
+ // Check if address is whitelisted
128
+ const isAllowed = await epistery.isWhitelisted('0x1234...');
129
+
130
+ // Get full whitelist
131
+ const whitelist = await epistery.getWhitelist();
132
+ ```
133
+
134
+ Whitelist data is stored on the blockchain and managed through your domain's wallet.
135
+
136
+ ### 4. CLI Tools
137
+
138
+ The Epistery CLI enables authenticated API requests from the command line or automation scripts:
139
+
140
+ ```bash
141
+ # Initialize a CLI wallet
142
+ epistery initialize localhost
143
+ epistery set-default localhost
144
+
145
+ # Make authenticated GET request
146
+ epistery curl https://api.example.com/data
147
+
148
+ # POST request with data
149
+ epistery curl -X POST -d '{"title":"Test"}' https://api.example.com/wiki/Test
150
+
151
+ # Use specific wallet
152
+ epistery curl -w production.example.com https://api.example.com/data
153
+ ```
154
+
155
+ Perfect for:
156
+ - Testing authenticated endpoints
157
+ - Building automation scripts
158
+ - Creating bots and agents
159
+ - CI/CD integration
160
+
161
+ See [CLI.md](CLI.md) for complete CLI documentation.
162
+
163
+ ## Configuration
164
+
165
+ Epistery uses a filesystem-based configuration system stored in `~/.epistery/`:
166
+
167
+ ```
168
+ ~/.epistery/
169
+ ├── config.ini # Global settings
170
+ ├── mydomain.com/
171
+ │ ├── config.ini # Domain wallet & provider
172
+ │ └── sessions/ # Session data
173
+ └── .ssl/
174
+ └── mydomain.com/ # SSL certificates
175
+ ```
176
+
177
+ ### Root Config (`~/.epistery/config.ini`)
178
+
179
+ ```ini
180
+ [profile]
181
+ name=Your Name
182
+ email=you@example.com
183
+
184
+ [ipfs]
185
+ url=https://rootz.digital/api/v0
186
+
187
+ [default.provider]
188
+ chainId=420420422
189
+ name=polkadot-hub-testnet
190
+ rpc=https://testnet-passet-hub-eth-rpc.polkadot.io
191
+ ```
192
+
193
+ ### Domain Config (`~/.epistery/mydomain.com/config.ini`)
194
+
195
+ ```ini
196
+ [domain]
197
+ domain=mydomain.com
198
+
199
+ [wallet]
200
+ address=0x...
201
+ mnemonic=word word word...
202
+ publicKey=0x04...
203
+ privateKey=0x...
204
+
205
+ [provider]
206
+ chainId=420420422
207
+ name=polkadot-hub-testnet
208
+ rpc=https://testnet-passet-hub-eth-rpc.polkadot.io
209
+ ```
210
+
211
+ ## Advanced Usage
212
+
213
+ ### Custom Authentication
214
+
215
+ Integrate with your existing user system:
216
+
217
+ ```javascript
218
+ const epistery = await Epistery.connect({
219
+ authentication: async (clientInfo) => {
220
+ // clientInfo: { address, publicKey }
221
+
222
+ // Look up user in your database
223
+ const user = await db.users.findOne({
224
+ walletAddress: clientInfo.address
225
+ });
226
+
227
+ if (!user) return null;
228
+
229
+ // Return profile data
230
+ return {
231
+ id: user.id,
232
+ username: user.username,
233
+ permissions: user.permissions
234
+ };
235
+ },
236
+ onAuthenticated: async (clientInfo, req, res) => {
237
+ // Called after successful authentication
238
+ // clientInfo includes: address, publicKey, profile, authenticated
239
+
240
+ // Set up session, log authentication, etc.
241
+ req.session.userId = clientInfo.profile.id;
242
+ }
243
+ });
244
+ ```
245
+
246
+ ### Configuration Management
247
+
248
+ Use Epistery's Config class for secure, path-based configuration:
249
+
250
+ ```javascript
251
+ import { Config } from 'epistery';
252
+
253
+ const config = new Config('epistery');
254
+
255
+ // Navigate filesystem-like paths
256
+ config.setPath('/');
257
+ config.load();
258
+ config.data.profile.email = 'user@example.com';
259
+ config.save();
260
+
261
+ // Domain-specific config
262
+ config.setPath('/mydomain.com');
263
+ config.load();
264
+ config.data.verified = true;
265
+ config.save();
266
+
267
+ // Arbitrary paths
268
+ config.setPath('/.ssl/mydomain.com');
269
+ config.load();
270
+ config.data.certData = '...';
271
+ config.save();
272
+ ```
273
+
274
+ ## Architecture
275
+
276
+ Epistery follows a plugin architecture that integrates seamlessly with Express.js applications:
277
+
278
+ - **Server Module** (`/src/epistery.ts`): Core wallet and data wallet operations
279
+ - **Client Libraries** (`/client/*.js`): Browser-side authentication and data wallet tools
280
+ - **CLI** (`/cli/epistery.mjs`): Command-line interface for authenticated requests
281
+ - **Utils** (`/src/utils/`): Configuration, crypto operations, and Aqua protocol implementation
282
+
283
+ All endpoints follow RFC 8615 well-known URIs standard for service discovery.
284
+
285
+ See [Architecture.md](Architecture.md) for detailed architecture documentation.
286
+
287
+ ## Use Cases
288
+
289
+ - **Decentralized Wikis**: User authentication and content ownership without central accounts
290
+ - **API Authentication**: Replace API keys with wallet-based authentication
291
+ - **Content Attribution**: Track content provenance and ownership on-chain
292
+ - **Access Control**: Manage permissions through blockchain whitelists
293
+ - **Bot/Agent Authentication**: Secure automation with wallet-based identity
294
+
295
+ ## Security
296
+
297
+ - Domain configs stored with 0600 permissions (user-only access)
298
+ - Private keys never transmitted (only signatures)
299
+ - Each domain has isolated wallet
300
+ - Session cookies saved securely per domain
301
+ - Key exchange uses ECDH for secure shared secrets
302
+
303
+ ## License
304
+
305
+ MIT License - see [LICENSE](LICENSE) for details
306
+
307
+ ## Links
46
308
 
47
- A data wallet is data with chain. The data wallet attaches to the source object with a hash and is used to track
48
- the provenance, manipulation and usage of the data, per instruction by the owner. The epistery enables IPFS as a
49
- default storage option for uploaded objects, but there is no requirement to load the data itself on chain, just
50
- its accounting.
309
+ - **Homepage**: https://epistery.com
310
+ - **Repository**: https://github.com/rootz-global/epistery
311
+ - **Documentation**: See [CLI.md](CLI.md), [Architecture.md](Architecture.md), [SESSION.md](SESSION.md)