@0xsequence/guard 1.1.12 → 1.1.14

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.
@@ -137,11 +137,12 @@ const buildResponse = res => {
137
137
 
138
138
  const fetch = typeof global === 'object' ? global.fetch : window.fetch;
139
139
  class GuardSigner {
140
- constructor(address, url, appendSuffix = false) {
140
+ constructor(address, url, appendSuffix = false, onError) {
141
141
  this.requests = new Map();
142
142
  this.address = address;
143
143
  this.url = url;
144
144
  this.appendSuffix = appendSuffix;
145
+ this.onError = onError;
145
146
  this.guard = new Guard(url, fetch);
146
147
  }
147
148
  async getAddress() {
@@ -201,10 +202,13 @@ class GuardSigner {
201
202
  this.requests.delete(id);
202
203
  }
203
204
  } catch (e) {
205
+ console.log('in GuardSigner.evaluateRequest: ', e);
204
206
  // The guard signer may reject the request for a number of reasons
205
207
  // like for example, if it's being the first signer (it waits for other signers to sign first)
206
- // for now we ignore all errors, but we should probably handle them
207
- // TODO: Filter real errors from control flow errors
208
+ if (e.cause.includes('signer does not match latest image hash')) {
209
+ var _this$onError;
210
+ (_this$onError = this.onError) == null ? void 0 : _this$onError.call(this, e);
211
+ }
208
212
  }
209
213
  }
210
214
  suffix() {
@@ -137,11 +137,12 @@ const buildResponse = res => {
137
137
 
138
138
  const fetch = typeof global === 'object' ? global.fetch : window.fetch;
139
139
  class GuardSigner {
140
- constructor(address, url, appendSuffix = false) {
140
+ constructor(address, url, appendSuffix = false, onError) {
141
141
  this.requests = new Map();
142
142
  this.address = address;
143
143
  this.url = url;
144
144
  this.appendSuffix = appendSuffix;
145
+ this.onError = onError;
145
146
  this.guard = new Guard(url, fetch);
146
147
  }
147
148
  async getAddress() {
@@ -201,10 +202,13 @@ class GuardSigner {
201
202
  this.requests.delete(id);
202
203
  }
203
204
  } catch (e) {
205
+ console.log('in GuardSigner.evaluateRequest: ', e);
204
206
  // The guard signer may reject the request for a number of reasons
205
207
  // like for example, if it's being the first signer (it waits for other signers to sign first)
206
- // for now we ignore all errors, but we should probably handle them
207
- // TODO: Filter real errors from control flow errors
208
+ if (e.cause.includes('signer does not match latest image hash')) {
209
+ var _this$onError;
210
+ (_this$onError = this.onError) == null ? void 0 : _this$onError.call(this, e);
211
+ }
208
212
  }
209
213
  }
210
214
  suffix() {
@@ -133,11 +133,12 @@ const buildResponse = res => {
133
133
 
134
134
  const fetch = typeof global === 'object' ? global.fetch : window.fetch;
135
135
  class GuardSigner {
136
- constructor(address, url, appendSuffix = false) {
136
+ constructor(address, url, appendSuffix = false, onError) {
137
137
  this.requests = new Map();
138
138
  this.address = address;
139
139
  this.url = url;
140
140
  this.appendSuffix = appendSuffix;
141
+ this.onError = onError;
141
142
  this.guard = new Guard(url, fetch);
142
143
  }
143
144
  async getAddress() {
@@ -197,10 +198,13 @@ class GuardSigner {
197
198
  this.requests.delete(id);
198
199
  }
199
200
  } catch (e) {
201
+ console.log('in GuardSigner.evaluateRequest: ', e);
200
202
  // The guard signer may reject the request for a number of reasons
201
203
  // like for example, if it's being the first signer (it waits for other signers to sign first)
202
- // for now we ignore all errors, but we should probably handle them
203
- // TODO: Filter real errors from control flow errors
204
+ if (e.cause.includes('signer does not match latest image hash')) {
205
+ var _this$onError;
206
+ (_this$onError = this.onError) == null ? void 0 : _this$onError.call(this, e);
207
+ }
204
208
  }
205
209
  }
206
210
  suffix() {
@@ -4,9 +4,10 @@ export declare class GuardSigner implements signers.SapientSigner {
4
4
  readonly address: string;
5
5
  readonly url: string;
6
6
  readonly appendSuffix: boolean;
7
+ private readonly onError?;
7
8
  private guard;
8
9
  private requests;
9
- constructor(address: string, url: string, appendSuffix?: boolean);
10
+ constructor(address: string, url: string, appendSuffix?: boolean, onError?: ((err: Error) => void) | undefined);
10
11
  getAddress(): Promise<string>;
11
12
  requestSignature(id: string, _message: BytesLike, metadata: Object, callbacks: {
12
13
  onSignature: (signature: BytesLike) => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@0xsequence/guard",
3
- "version": "1.1.12",
3
+ "version": "1.1.14",
4
4
  "description": "guard sub-package for Sequence",
5
5
  "repository": "https://github.com/0xsequence/sequence.js/tree/master/packages/guard",
6
6
  "source": "src/index.ts",
@@ -10,8 +10,8 @@
10
10
  "license": "Apache-2.0",
11
11
  "dependencies": {
12
12
  "ethers": "^5.7.2",
13
- "@0xsequence/core": "1.1.12",
14
- "@0xsequence/signhub": "1.1.12"
13
+ "@0xsequence/core": "1.1.14",
14
+ "@0xsequence/signhub": "1.1.14"
15
15
  },
16
16
  "files": [
17
17
  "src",
package/src/signer.ts CHANGED
@@ -20,7 +20,8 @@ export class GuardSigner implements signers.SapientSigner {
20
20
  constructor(
21
21
  public readonly address: string,
22
22
  public readonly url: string,
23
- public readonly appendSuffix: boolean = false
23
+ public readonly appendSuffix: boolean = false,
24
+ private readonly onError?: (err: Error) => void
24
25
  ) {
25
26
  this.guard = new Guard(url, fetch)
26
27
  }
@@ -103,10 +104,12 @@ export class GuardSigner implements signers.SapientSigner {
103
104
  this.requests.delete(id)
104
105
  }
105
106
  } catch (e) {
107
+ console.log('in GuardSigner.evaluateRequest: ', e)
106
108
  // The guard signer may reject the request for a number of reasons
107
109
  // like for example, if it's being the first signer (it waits for other signers to sign first)
108
- // for now we ignore all errors, but we should probably handle them
109
- // TODO: Filter real errors from control flow errors
110
+ if (e.cause.includes('signer does not match latest image hash')) {
111
+ this.onError?.(e)
112
+ }
110
113
  }
111
114
  }
112
115