@0xsequence/guard 1.10.15 → 2.0.1
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.
|
@@ -480,9 +480,9 @@ class GuardSigner {
|
|
|
480
480
|
return (await this.guard.signWith({
|
|
481
481
|
signer: this.address,
|
|
482
482
|
request: {
|
|
483
|
-
msg: ethers.ethers.
|
|
483
|
+
msg: ethers.ethers.hexlify(message),
|
|
484
484
|
auxData: this.packMsgAndSig(metadata.address, metadata.digest, encoded, metadata.chainId),
|
|
485
|
-
chainId:
|
|
485
|
+
chainId: Number(metadata.chainId)
|
|
486
486
|
},
|
|
487
487
|
token: guardTotpCode ? {
|
|
488
488
|
id: AuthMethod.TOTP,
|
|
@@ -610,10 +610,10 @@ class GuardSigner {
|
|
|
610
610
|
return codes;
|
|
611
611
|
}
|
|
612
612
|
packMsgAndSig(address, msg, sig, chainId) {
|
|
613
|
-
return ethers.ethers.
|
|
613
|
+
return ethers.ethers.AbiCoder.defaultAbiCoder().encode(['address', 'uint256', 'bytes', 'bytes'], [address, chainId, msg, sig]);
|
|
614
614
|
}
|
|
615
615
|
suffix() {
|
|
616
|
-
return this.appendSuffix ? [3] : [];
|
|
616
|
+
return new Uint8Array(this.appendSuffix ? [3] : []);
|
|
617
617
|
}
|
|
618
618
|
}
|
|
619
619
|
let AuthMethod = /*#__PURE__*/function (AuthMethod) {
|
|
@@ -646,7 +646,7 @@ async function signOwnershipProof(proof) {
|
|
|
646
646
|
walletAddress: proof.walletAddress,
|
|
647
647
|
timestamp,
|
|
648
648
|
signerAddress,
|
|
649
|
-
signature: ethers.ethers.
|
|
649
|
+
signature: ethers.ethers.hexlify(await signer.sign(digest, {}))
|
|
650
650
|
};
|
|
651
651
|
}
|
|
652
652
|
}
|
|
@@ -678,7 +678,7 @@ function getOwnershipProofTypedData(wallet, timestamp) {
|
|
|
678
678
|
}]
|
|
679
679
|
},
|
|
680
680
|
message: {
|
|
681
|
-
wallet: ethers.ethers.
|
|
681
|
+
wallet: ethers.ethers.getAddress(wallet),
|
|
682
682
|
timestamp: toUTCString(timestamp)
|
|
683
683
|
}
|
|
684
684
|
};
|
|
@@ -480,9 +480,9 @@ class GuardSigner {
|
|
|
480
480
|
return (await this.guard.signWith({
|
|
481
481
|
signer: this.address,
|
|
482
482
|
request: {
|
|
483
|
-
msg: ethers.ethers.
|
|
483
|
+
msg: ethers.ethers.hexlify(message),
|
|
484
484
|
auxData: this.packMsgAndSig(metadata.address, metadata.digest, encoded, metadata.chainId),
|
|
485
|
-
chainId:
|
|
485
|
+
chainId: Number(metadata.chainId)
|
|
486
486
|
},
|
|
487
487
|
token: guardTotpCode ? {
|
|
488
488
|
id: AuthMethod.TOTP,
|
|
@@ -610,10 +610,10 @@ class GuardSigner {
|
|
|
610
610
|
return codes;
|
|
611
611
|
}
|
|
612
612
|
packMsgAndSig(address, msg, sig, chainId) {
|
|
613
|
-
return ethers.ethers.
|
|
613
|
+
return ethers.ethers.AbiCoder.defaultAbiCoder().encode(['address', 'uint256', 'bytes', 'bytes'], [address, chainId, msg, sig]);
|
|
614
614
|
}
|
|
615
615
|
suffix() {
|
|
616
|
-
return this.appendSuffix ? [3] : [];
|
|
616
|
+
return new Uint8Array(this.appendSuffix ? [3] : []);
|
|
617
617
|
}
|
|
618
618
|
}
|
|
619
619
|
let AuthMethod = /*#__PURE__*/function (AuthMethod) {
|
|
@@ -646,7 +646,7 @@ async function signOwnershipProof(proof) {
|
|
|
646
646
|
walletAddress: proof.walletAddress,
|
|
647
647
|
timestamp,
|
|
648
648
|
signerAddress,
|
|
649
|
-
signature: ethers.ethers.
|
|
649
|
+
signature: ethers.ethers.hexlify(await signer.sign(digest, {}))
|
|
650
650
|
};
|
|
651
651
|
}
|
|
652
652
|
}
|
|
@@ -678,7 +678,7 @@ function getOwnershipProofTypedData(wallet, timestamp) {
|
|
|
678
678
|
}]
|
|
679
679
|
},
|
|
680
680
|
message: {
|
|
681
|
-
wallet: ethers.ethers.
|
|
681
|
+
wallet: ethers.ethers.getAddress(wallet),
|
|
682
682
|
timestamp: toUTCString(timestamp)
|
|
683
683
|
}
|
|
684
684
|
};
|
|
@@ -476,9 +476,9 @@ class GuardSigner {
|
|
|
476
476
|
return (await this.guard.signWith({
|
|
477
477
|
signer: this.address,
|
|
478
478
|
request: {
|
|
479
|
-
msg: ethers.
|
|
479
|
+
msg: ethers.hexlify(message),
|
|
480
480
|
auxData: this.packMsgAndSig(metadata.address, metadata.digest, encoded, metadata.chainId),
|
|
481
|
-
chainId:
|
|
481
|
+
chainId: Number(metadata.chainId)
|
|
482
482
|
},
|
|
483
483
|
token: guardTotpCode ? {
|
|
484
484
|
id: AuthMethod.TOTP,
|
|
@@ -606,10 +606,10 @@ class GuardSigner {
|
|
|
606
606
|
return codes;
|
|
607
607
|
}
|
|
608
608
|
packMsgAndSig(address, msg, sig, chainId) {
|
|
609
|
-
return ethers.
|
|
609
|
+
return ethers.AbiCoder.defaultAbiCoder().encode(['address', 'uint256', 'bytes', 'bytes'], [address, chainId, msg, sig]);
|
|
610
610
|
}
|
|
611
611
|
suffix() {
|
|
612
|
-
return this.appendSuffix ? [3] : [];
|
|
612
|
+
return new Uint8Array(this.appendSuffix ? [3] : []);
|
|
613
613
|
}
|
|
614
614
|
}
|
|
615
615
|
let AuthMethod = /*#__PURE__*/function (AuthMethod) {
|
|
@@ -642,7 +642,7 @@ async function signOwnershipProof(proof) {
|
|
|
642
642
|
walletAddress: proof.walletAddress,
|
|
643
643
|
timestamp,
|
|
644
644
|
signerAddress,
|
|
645
|
-
signature: ethers.
|
|
645
|
+
signature: ethers.hexlify(await signer.sign(digest, {}))
|
|
646
646
|
};
|
|
647
647
|
}
|
|
648
648
|
}
|
|
@@ -674,7 +674,7 @@ function getOwnershipProofTypedData(wallet, timestamp) {
|
|
|
674
674
|
}]
|
|
675
675
|
},
|
|
676
676
|
message: {
|
|
677
|
-
wallet: ethers.
|
|
677
|
+
wallet: ethers.getAddress(wallet),
|
|
678
678
|
timestamp: toUTCString(timestamp)
|
|
679
679
|
}
|
|
680
680
|
};
|
|
@@ -2,7 +2,7 @@ import { Account } from '@0xsequence/account';
|
|
|
2
2
|
import { commons } from '@0xsequence/core';
|
|
3
3
|
import { signers, Status } from '@0xsequence/signhub';
|
|
4
4
|
import { TypedData } from '@0xsequence/utils';
|
|
5
|
-
import {
|
|
5
|
+
import { ethers } from 'ethers';
|
|
6
6
|
import { RecoveryCode as GuardRecoveryCode } from "./guard.gen.js";
|
|
7
7
|
export declare class GuardSigner implements signers.SapientSigner {
|
|
8
8
|
readonly address: string;
|
|
@@ -14,7 +14,7 @@ export declare class GuardSigner implements signers.SapientSigner {
|
|
|
14
14
|
buildDeployTransaction(_metadata: object): Promise<commons.transaction.TransactionBundle | undefined>;
|
|
15
15
|
predecorateSignedTransactions(_metadata: object): Promise<commons.transaction.SignedTransactionBundle[]>;
|
|
16
16
|
decorateTransactions(bundle: commons.transaction.IntendedTransactionBundle, _metadata: object): Promise<commons.transaction.IntendedTransactionBundle>;
|
|
17
|
-
sign(message: BytesLike, metadata: object): Promise<BytesLike>;
|
|
17
|
+
sign(message: ethers.BytesLike, metadata: object): Promise<ethers.BytesLike>;
|
|
18
18
|
notifyStatusChange(_id: string, _status: Status, _metadata: object): void;
|
|
19
19
|
getAuthMethods(proof: OwnershipProof): Promise<{
|
|
20
20
|
methods: AuthMethod[];
|
|
@@ -29,7 +29,7 @@ export declare class GuardSigner implements signers.SapientSigner {
|
|
|
29
29
|
getRecoveryCodes(proof: AuthUpdateProof): Promise<RecoveryCode[]>;
|
|
30
30
|
resetRecoveryCodes(proof: AuthUpdateProof): Promise<RecoveryCode[]>;
|
|
31
31
|
private packMsgAndSig;
|
|
32
|
-
suffix(): BytesLike;
|
|
32
|
+
suffix(): ethers.BytesLike;
|
|
33
33
|
}
|
|
34
34
|
export type RecoveryCode = GuardRecoveryCode;
|
|
35
35
|
export declare enum AuthMethod {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@0xsequence/guard",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.1",
|
|
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",
|
|
@@ -9,11 +9,11 @@
|
|
|
9
9
|
"author": "Horizon Blockchain Games",
|
|
10
10
|
"license": "Apache-2.0",
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"ethers": "^
|
|
13
|
-
"@0xsequence/account": "
|
|
14
|
-
"@0xsequence/core": "
|
|
15
|
-
"@0xsequence/signhub": "
|
|
16
|
-
"@0xsequence/utils": "
|
|
12
|
+
"ethers": "^6.13.0",
|
|
13
|
+
"@0xsequence/account": "2.0.1",
|
|
14
|
+
"@0xsequence/core": "2.0.1",
|
|
15
|
+
"@0xsequence/signhub": "2.0.1",
|
|
16
|
+
"@0xsequence/utils": "2.0.1"
|
|
17
17
|
},
|
|
18
18
|
"files": [
|
|
19
19
|
"src",
|
package/src/signer.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { Account } from '@0xsequence/account'
|
|
|
2
2
|
import { commons, universal } from '@0xsequence/core'
|
|
3
3
|
import { signers, Status } from '@0xsequence/signhub'
|
|
4
4
|
import { encodeTypedDataDigest, TypedData } from '@0xsequence/utils'
|
|
5
|
-
import {
|
|
5
|
+
import { ethers } from 'ethers'
|
|
6
6
|
import { AuthMethodsReturn, Guard, RecoveryCode as GuardRecoveryCode } from './guard.gen'
|
|
7
7
|
|
|
8
8
|
const fetch = globalThis.fetch
|
|
@@ -37,7 +37,7 @@ export class GuardSigner implements signers.SapientSigner {
|
|
|
37
37
|
return bundle
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
async sign(message: BytesLike, metadata: object): Promise<BytesLike> {
|
|
40
|
+
async sign(message: ethers.BytesLike, metadata: object): Promise<ethers.BytesLike> {
|
|
41
41
|
if (!commons.isWalletSignRequestMetadata(metadata)) {
|
|
42
42
|
throw new Error('expected sequence signature request metadata')
|
|
43
43
|
}
|
|
@@ -53,9 +53,9 @@ export class GuardSigner implements signers.SapientSigner {
|
|
|
53
53
|
await this.guard.signWith({
|
|
54
54
|
signer: this.address,
|
|
55
55
|
request: {
|
|
56
|
-
msg: ethers.
|
|
56
|
+
msg: ethers.hexlify(message),
|
|
57
57
|
auxData: this.packMsgAndSig(metadata.address, metadata.digest, encoded, metadata.chainId),
|
|
58
|
-
chainId:
|
|
58
|
+
chainId: Number(metadata.chainId)
|
|
59
59
|
},
|
|
60
60
|
token: guardTotpCode ? { id: AuthMethod.TOTP, token: guardTotpCode } : undefined
|
|
61
61
|
})
|
|
@@ -170,12 +170,12 @@ export class GuardSigner implements signers.SapientSigner {
|
|
|
170
170
|
return codes
|
|
171
171
|
}
|
|
172
172
|
|
|
173
|
-
private packMsgAndSig(address: string, msg: BytesLike, sig: BytesLike, chainId: ethers.BigNumberish): string {
|
|
174
|
-
return ethers.
|
|
173
|
+
private packMsgAndSig(address: string, msg: ethers.BytesLike, sig: ethers.BytesLike, chainId: ethers.BigNumberish): string {
|
|
174
|
+
return ethers.AbiCoder.defaultAbiCoder().encode(['address', 'uint256', 'bytes', 'bytes'], [address, chainId, msg, sig])
|
|
175
175
|
}
|
|
176
176
|
|
|
177
|
-
suffix(): BytesLike {
|
|
178
|
-
return this.appendSuffix ? [3] : []
|
|
177
|
+
suffix(): ethers.BytesLike {
|
|
178
|
+
return new Uint8Array(this.appendSuffix ? [3] : [])
|
|
179
179
|
}
|
|
180
180
|
}
|
|
181
181
|
|
|
@@ -229,7 +229,7 @@ export async function signOwnershipProof(proof: Exclude<OwnershipProof, { jwt: s
|
|
|
229
229
|
walletAddress: proof.walletAddress,
|
|
230
230
|
timestamp,
|
|
231
231
|
signerAddress,
|
|
232
|
-
signature: ethers.
|
|
232
|
+
signature: ethers.hexlify(await signer.sign(digest, {}))
|
|
233
233
|
}
|
|
234
234
|
}
|
|
235
235
|
}
|
|
@@ -265,7 +265,7 @@ export function getOwnershipProofTypedData(wallet: string, timestamp: Date): Typ
|
|
|
265
265
|
]
|
|
266
266
|
},
|
|
267
267
|
message: {
|
|
268
|
-
wallet: ethers.
|
|
268
|
+
wallet: ethers.getAddress(wallet),
|
|
269
269
|
timestamp: toUTCString(timestamp)
|
|
270
270
|
}
|
|
271
271
|
}
|
|
@@ -283,7 +283,7 @@ export function getAuthUpdateProofTypedData(timestamp: Date): TypedData {
|
|
|
283
283
|
}
|
|
284
284
|
}
|
|
285
285
|
|
|
286
|
-
const domain: TypedDataDomain = {
|
|
286
|
+
const domain: ethers.TypedDataDomain = {
|
|
287
287
|
name: 'Sequence Guard',
|
|
288
288
|
version: '1',
|
|
289
289
|
chainId: 1
|