epistery 2.2.1 → 2.2.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/client/wallet.js CHANGED
@@ -54,9 +54,26 @@ export class Wallet {
54
54
  address: this.address,
55
55
  publicKey: this.publicKey,
56
56
  source: this.source,
57
+ // Contract binding is a base-class fact — persist it for EVERY rivet
58
+ // kind, or adopting an identity silently unbinds on reload.
59
+ contractAddress: this.contractAddress,
60
+ rivetAddress: this.rivetAddress,
57
61
  };
58
62
  }
59
63
 
64
+ // Bind this rivet to an identity contract. A base-class capability: any
65
+ // rivet kind (browser, FIDO, web3) can be a signer on a contract. Does
66
+ // NOT flip `address` — the device key stays `address`/`rivetAddress`;
67
+ // the contract is a separate fact exposed via contractAddress /
68
+ // identityAddress.
69
+ upgradeToContract(contractAddress) {
70
+ if (this.contractAddress) {
71
+ throw new Error("Rivet is already using an identity contract");
72
+ }
73
+ this.rivetAddress = this.address;
74
+ this.contractAddress = contractAddress;
75
+ }
76
+
60
77
  // Factory method to create appropriate wallet type from saved data.
61
78
  // The three rivet types — web3, browser (rivet), and fido — are the only
62
79
  // valid identities. Anything else is a legacy/unsupported entry (e.g. the
@@ -231,6 +248,8 @@ export class Web3Wallet extends Wallet {
231
248
  wallet.web3Address = data.web3Address || data.address;
232
249
  wallet.label = data.label || null;
233
250
  wallet.createdAt = data.createdAt || null;
251
+ wallet.contractAddress = data.contractAddress || null;
252
+ wallet.rivetAddress = data.rivetAddress || null;
234
253
  wallet.canPeerEncrypt = !wallet._legacy;
235
254
  // Lazy: the plugin reconnect + unlock signature happen on first use,
236
255
  // not at restore — a locked wallet still reports address/publicKey.
@@ -369,8 +388,6 @@ export class RivetWallet extends Wallet {
369
388
  createdAt: this.createdAt,
370
389
  lastUpdated: this.lastUpdated,
371
390
  encryptedPrivateKey: this.encryptedPrivateKey,
372
- contractAddress: this.contractAddress,
373
- rivetAddress: this.rivetAddress,
374
391
  associations: this.associations,
375
392
  };
376
393
  }
@@ -1093,23 +1110,10 @@ export class RivetWallet extends Wallet {
1093
1110
 
1094
1111
  /**
1095
1112
  * Upgrades this rivet to use an identity contract
1096
- * Updates the wallet to present the contract address instead of rivet address
1097
1113
  * @param {string} contractAddress - The deployed identity contract address
1098
1114
  */
1099
1115
  upgradeToContract(contractAddress) {
1100
- if (this.contractAddress) {
1101
- throw new Error("Rivet is already using an identity contract");
1102
- }
1103
-
1104
- // Do NOT flip `address` to the contract. `address` stays the rivet (device
1105
- // key) for the life of the wallet; the contract is a separate fact exposed
1106
- // via contractAddress / identityAddress. Flipping used to make the device
1107
- // wallet masquerade as its contract — the device list then showed the
1108
- // contract address, and every consumer that read `address` expecting the
1109
- // signer was wrong. rivetAddress is kept set (== address) for the
1110
- // signerAddress getter and a stable persisted shape.
1111
- this.rivetAddress = this.address;
1112
- this.contractAddress = contractAddress;
1116
+ super.upgradeToContract(contractAddress);
1113
1117
  this.type = "Contract";
1114
1118
  this.lastUpdated = Date.now();
1115
1119
  }
@@ -1162,6 +1166,8 @@ export class FidoWallet extends Wallet {
1162
1166
  wallet.label = data.label;
1163
1167
  wallet.createdAt = data.createdAt;
1164
1168
  wallet.lastUpdated = data.lastUpdated;
1169
+ wallet.contractAddress = data.contractAddress || null;
1170
+ wallet.rivetAddress = data.rivetAddress || null;
1165
1171
  return wallet;
1166
1172
  }
1167
1173
 
package/client/witness.js CHANGED
@@ -393,6 +393,12 @@ export default class Witness {
393
393
  if (!this.wallet || this.wallet.source !== "web3" || !this.serverInfo) {
394
394
  return;
395
395
  }
396
+ // Locked-rivet web3 wallets restore lazily — no provider until first
397
+ // plugin use. Chain compatibility only matters when the plugin itself
398
+ // sends a tx (legacy path), and that path switches chains at tx time.
399
+ if (!this.wallet.provider || typeof this.wallet.provider.getNetwork !== "function") {
400
+ return;
401
+ }
396
402
 
397
403
  try {
398
404
  const targetChainId = this.serverInfo.chainId;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "epistery",
3
- "version": "2.2.1",
3
+ "version": "2.2.2",
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",