@0xsequence/guard 2.1.6 → 2.1.8
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.
|
@@ -438,14 +438,25 @@ const webrpcErrorByCode = {
|
|
|
438
438
|
[3000]: NotFoundError
|
|
439
439
|
};
|
|
440
440
|
|
|
441
|
-
const fetch = globalThis.fetch;
|
|
442
441
|
class GuardSigner {
|
|
443
|
-
constructor(address, url, appendSuffix = false) {
|
|
442
|
+
constructor(address, url, appendSuffix = false, projectAccessKey) {
|
|
444
443
|
this.address = address;
|
|
445
444
|
this.url = url;
|
|
446
445
|
this.appendSuffix = appendSuffix;
|
|
446
|
+
this.projectAccessKey = projectAccessKey;
|
|
447
447
|
this.guard = void 0;
|
|
448
|
-
this.
|
|
448
|
+
this._fetch = (input, init) => {
|
|
449
|
+
const headers = {};
|
|
450
|
+
const projectAccessKey = this.projectAccessKey;
|
|
451
|
+
if (projectAccessKey && projectAccessKey.length > 0) {
|
|
452
|
+
headers['X-Access-Key'] = projectAccessKey;
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
// before the request is made
|
|
456
|
+
init.headers = _extends({}, init.headers, headers);
|
|
457
|
+
return fetch(input, init);
|
|
458
|
+
};
|
|
459
|
+
this.guard = new Guard(url, this._fetch);
|
|
449
460
|
}
|
|
450
461
|
async getAddress() {
|
|
451
462
|
return this.address;
|
|
@@ -438,14 +438,25 @@ const webrpcErrorByCode = {
|
|
|
438
438
|
[3000]: NotFoundError
|
|
439
439
|
};
|
|
440
440
|
|
|
441
|
-
const fetch = globalThis.fetch;
|
|
442
441
|
class GuardSigner {
|
|
443
|
-
constructor(address, url, appendSuffix = false) {
|
|
442
|
+
constructor(address, url, appendSuffix = false, projectAccessKey) {
|
|
444
443
|
this.address = address;
|
|
445
444
|
this.url = url;
|
|
446
445
|
this.appendSuffix = appendSuffix;
|
|
446
|
+
this.projectAccessKey = projectAccessKey;
|
|
447
447
|
this.guard = void 0;
|
|
448
|
-
this.
|
|
448
|
+
this._fetch = (input, init) => {
|
|
449
|
+
const headers = {};
|
|
450
|
+
const projectAccessKey = this.projectAccessKey;
|
|
451
|
+
if (projectAccessKey && projectAccessKey.length > 0) {
|
|
452
|
+
headers['X-Access-Key'] = projectAccessKey;
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
// before the request is made
|
|
456
|
+
init.headers = _extends({}, init.headers, headers);
|
|
457
|
+
return fetch(input, init);
|
|
458
|
+
};
|
|
459
|
+
this.guard = new Guard(url, this._fetch);
|
|
449
460
|
}
|
|
450
461
|
async getAddress() {
|
|
451
462
|
return this.address;
|
|
@@ -434,14 +434,25 @@ const webrpcErrorByCode = {
|
|
|
434
434
|
[3000]: NotFoundError
|
|
435
435
|
};
|
|
436
436
|
|
|
437
|
-
const fetch = globalThis.fetch;
|
|
438
437
|
class GuardSigner {
|
|
439
|
-
constructor(address, url, appendSuffix = false) {
|
|
438
|
+
constructor(address, url, appendSuffix = false, projectAccessKey) {
|
|
440
439
|
this.address = address;
|
|
441
440
|
this.url = url;
|
|
442
441
|
this.appendSuffix = appendSuffix;
|
|
442
|
+
this.projectAccessKey = projectAccessKey;
|
|
443
443
|
this.guard = void 0;
|
|
444
|
-
this.
|
|
444
|
+
this._fetch = (input, init) => {
|
|
445
|
+
const headers = {};
|
|
446
|
+
const projectAccessKey = this.projectAccessKey;
|
|
447
|
+
if (projectAccessKey && projectAccessKey.length > 0) {
|
|
448
|
+
headers['X-Access-Key'] = projectAccessKey;
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
// before the request is made
|
|
452
|
+
init.headers = _extends({}, init.headers, headers);
|
|
453
|
+
return fetch(input, init);
|
|
454
|
+
};
|
|
455
|
+
this.guard = new Guard(url, this._fetch);
|
|
445
456
|
}
|
|
446
457
|
async getAddress() {
|
|
447
458
|
return this.address;
|
|
@@ -8,8 +8,10 @@ export declare class GuardSigner implements signers.SapientSigner {
|
|
|
8
8
|
readonly address: string;
|
|
9
9
|
readonly url: string;
|
|
10
10
|
readonly appendSuffix: boolean;
|
|
11
|
+
readonly projectAccessKey?: string | undefined;
|
|
11
12
|
private guard;
|
|
12
|
-
constructor(address: string, url: string, appendSuffix?: boolean);
|
|
13
|
+
constructor(address: string, url: string, appendSuffix?: boolean, projectAccessKey?: string | undefined);
|
|
14
|
+
_fetch: (input: RequestInfo, init?: RequestInit) => Promise<Response>;
|
|
13
15
|
getAddress(): Promise<string>;
|
|
14
16
|
buildDeployTransaction(_metadata: object): Promise<commons.transaction.TransactionBundle | undefined>;
|
|
15
17
|
predecorateSignedTransactions(_metadata: object): Promise<commons.transaction.SignedTransactionBundle[]>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@0xsequence/guard",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.8",
|
|
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",
|
|
@@ -12,10 +12,10 @@
|
|
|
12
12
|
"ethers": ">=6"
|
|
13
13
|
},
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@0xsequence/account": "2.1.
|
|
16
|
-
"@0xsequence/core": "2.1.
|
|
17
|
-
"@0xsequence/
|
|
18
|
-
"@0xsequence/
|
|
15
|
+
"@0xsequence/account": "2.1.8",
|
|
16
|
+
"@0xsequence/core": "2.1.8",
|
|
17
|
+
"@0xsequence/signhub": "2.1.8",
|
|
18
|
+
"@0xsequence/utils": "2.1.8"
|
|
19
19
|
},
|
|
20
20
|
"devDependencies": {
|
|
21
21
|
"ethers": "6.13.4"
|
package/src/signer.ts
CHANGED
|
@@ -5,17 +5,31 @@ import { encodeTypedDataDigest, TypedData } from '@0xsequence/utils'
|
|
|
5
5
|
import { ethers } from 'ethers'
|
|
6
6
|
import { AuthMethodsReturn, Guard, RecoveryCode as GuardRecoveryCode } from './guard.gen'
|
|
7
7
|
|
|
8
|
-
const fetch = globalThis.fetch
|
|
9
|
-
|
|
10
8
|
export class GuardSigner implements signers.SapientSigner {
|
|
11
9
|
private guard: Guard
|
|
12
10
|
|
|
13
11
|
constructor(
|
|
14
12
|
public readonly address: string,
|
|
15
13
|
public readonly url: string,
|
|
16
|
-
public readonly appendSuffix: boolean = false
|
|
14
|
+
public readonly appendSuffix: boolean = false,
|
|
15
|
+
public readonly projectAccessKey?: string
|
|
17
16
|
) {
|
|
18
|
-
this.guard = new Guard(url,
|
|
17
|
+
this.guard = new Guard(url, this._fetch)
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
_fetch = (input: RequestInfo, init?: RequestInit): Promise<Response> => {
|
|
21
|
+
const headers: { [key: string]: any } = {}
|
|
22
|
+
|
|
23
|
+
const projectAccessKey = this.projectAccessKey
|
|
24
|
+
|
|
25
|
+
if (projectAccessKey && projectAccessKey.length > 0) {
|
|
26
|
+
headers['X-Access-Key'] = projectAccessKey
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// before the request is made
|
|
30
|
+
init!.headers = { ...init!.headers, ...headers }
|
|
31
|
+
|
|
32
|
+
return fetch(input, init)
|
|
19
33
|
}
|
|
20
34
|
|
|
21
35
|
async getAddress(): Promise<string> {
|