epistery 1.3.4 → 1.3.6

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/client/witness.js CHANGED
@@ -203,8 +203,8 @@ export default class Witness {
203
203
  // Verify chain compatibility and switch if needed
204
204
  await witness.ensureChainCompatibility();
205
205
 
206
- // Perform key exchange only if no session exists yet
207
- if (!options.skipKeyExchange && !witness.server?.identified) {
206
+ // Establish mutual proof of identity
207
+ if (!options.skipKeyExchange) {
208
208
  await witness.performKeyExchange();
209
209
  }
210
210
 
@@ -356,6 +356,19 @@ export default class Witness {
356
356
  const signingAddress = this.wallet.rivetAddress || this.wallet.address;
357
357
  const identityAddress = this.wallet.address;
358
358
 
359
+ // Check if session cookie already identifies this wallet
360
+ try {
361
+ const check = await fetch(`${this.rootPath}/connect`, { credentials: "include" });
362
+ if (check.ok) {
363
+ const session = await check.json();
364
+ if (session.address && session.address.toLowerCase() === signingAddress.toLowerCase()) {
365
+ return;
366
+ }
367
+ }
368
+ } catch (e) {
369
+ // No valid session, proceed with key exchange
370
+ }
371
+
359
372
  // Create a message to sign for identity proof
360
373
  const challenge = this.generateChallenge();
361
374
  const message = `Epistery Key Exchange - ${signingAddress} - ${challenge}`;
package/index.mjs CHANGED
@@ -42,6 +42,15 @@ class EpisteryAttach {
42
42
  this.domain = getDomainConfig(domain);
43
43
  }
44
44
 
45
+ /**
46
+ * Get the server wallet as an ethers.js Signer for the current domain.
47
+ * Used by OAuthServer, MCPServer, and agents that need signing capability.
48
+ */
49
+ get signer() {
50
+ if (!this.domainName) return null;
51
+ return Utils.InitServerWallet(this.domainName) || null;
52
+ }
53
+
45
54
  async attach(app, rootPath) {
46
55
  this.rootPath = rootPath || "/.well-known/epistery";
47
56
  app.locals.epistery = this;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "epistery",
3
- "version": "1.3.4",
3
+ "version": "1.3.6",
4
4
  "description": "Epistery brings blockchain capabilities to mundane web tasks like engagement metrics, authentication and commerce of all sorts.",
5
5
  "author": "Rootz Corp.",
6
6
  "license": "MIT",
@@ -9,6 +9,14 @@ import { Epistery } from "../dist/epistery.js";
9
9
  export default function connectRoutes(epistery) {
10
10
  const router = express.Router();
11
11
 
12
+ // Session check - returns current identity from cookie (via auth middleware)
13
+ router.get("/connect", (req, res) => {
14
+ if (req.episteryClient) {
15
+ return res.json({ address: req.episteryClient.address });
16
+ }
17
+ res.json({});
18
+ });
19
+
12
20
  // Key exchange endpoint - handles POST requests for key exchange
13
21
  router.post("/connect", async (req, res) => {
14
22
  try {