@atbash/sdk 0.10.5-dev.0 → 0.10.6-dev.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.
package/dist/index.js CHANGED
@@ -3520,11 +3520,15 @@ var Atbash = class _Atbash {
3520
3520
  * response bytes via the Rust core's `verifySignature`.
3521
3521
  */
3522
3522
  async judgeAction(action, context = "", options = {}) {
3523
- return this.track(
3524
- "judgeAction",
3525
- this.auth.pubkey,
3526
- () => this._judgeAction(action, context, options)
3527
- );
3523
+ return this.track("judgeAction", this.auth.pubkey, async () => {
3524
+ try {
3525
+ return await this._judgeAction(action, context, options);
3526
+ } catch (err) {
3527
+ if (!isEncryptionStateMismatch(err)) throw err;
3528
+ this._orgKeyFromChain = null;
3529
+ return await this._judgeAction(action, context, options);
3530
+ }
3531
+ });
3528
3532
  }
3529
3533
  async _judgeAction(action, context, options) {
3530
3534
  if (!action?.trim()) {
@@ -4198,6 +4202,10 @@ async function safeText(resp) {
4198
4202
  function errorMessage(err) {
4199
4203
  return err instanceof Error ? err.message : String(err);
4200
4204
  }
4205
+ function isEncryptionStateMismatch(err) {
4206
+ const msg = errorMessage(err);
4207
+ return msg.includes("must be a valid encryption envelope") || msg.includes("must be plaintext");
4208
+ }
4201
4209
  function stringifyArgs(args) {
4202
4210
  if (args === null || args === void 0) return "";
4203
4211
  if (typeof args === "string") return args;