@0xsequence/provider 1.2.1 → 1.2.3
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/0xsequence-provider.cjs.dev.js +14 -3
- package/dist/0xsequence-provider.cjs.prod.js +14 -3
- package/dist/0xsequence-provider.esm.js +14 -3
- package/dist/declarations/src/types.d.ts +3 -0
- package/package.json +10 -10
- package/src/transactions.ts +12 -1
- package/src/transports/wallet-request-handler.ts +2 -1
- package/src/types.ts +4 -0
|
@@ -8,6 +8,7 @@ var ethers = require('ethers');
|
|
|
8
8
|
var network = require('@0xsequence/network');
|
|
9
9
|
var core = require('@0xsequence/core');
|
|
10
10
|
var auth = require('@0xsequence/auth');
|
|
11
|
+
var abi = require('@0xsequence/abi');
|
|
11
12
|
|
|
12
13
|
function _extends() {
|
|
13
14
|
_extends = Object.assign ? Object.assign.bind() : function (target) {
|
|
@@ -2123,7 +2124,7 @@ function validateTransaction(wallet, transaction) {
|
|
|
2123
2124
|
if (transaction.to.toLowerCase() === wallet.toLowerCase()) {
|
|
2124
2125
|
if (transaction.data) {
|
|
2125
2126
|
const data = ethers.ethers.utils.arrayify(transaction.data);
|
|
2126
|
-
if (data.length >= 4) {
|
|
2127
|
+
if (data.length >= 4 && !isCreateContractCall(data)) {
|
|
2127
2128
|
throw new Error('self calls are forbidden');
|
|
2128
2129
|
}
|
|
2129
2130
|
}
|
|
@@ -2132,6 +2133,15 @@ function validateTransaction(wallet, transaction) {
|
|
|
2132
2133
|
throw new Error('delegate calls are forbidden');
|
|
2133
2134
|
}
|
|
2134
2135
|
}
|
|
2136
|
+
function isCreateContractCall(data) {
|
|
2137
|
+
const walletInterface = new ethers.ethers.utils.Interface(abi.walletContracts.mainModule.abi);
|
|
2138
|
+
try {
|
|
2139
|
+
walletInterface.decodeFunctionData('createContract', data);
|
|
2140
|
+
return true;
|
|
2141
|
+
} catch (_unused) {
|
|
2142
|
+
return false;
|
|
2143
|
+
}
|
|
2144
|
+
}
|
|
2135
2145
|
|
|
2136
2146
|
const SIGNER_READY_TIMEOUT = 10000;
|
|
2137
2147
|
class WalletRequestHandler {
|
|
@@ -2672,7 +2682,8 @@ class WalletRequestHandler {
|
|
|
2672
2682
|
const authOptions = {
|
|
2673
2683
|
app: options.app,
|
|
2674
2684
|
origin: options.origin,
|
|
2675
|
-
expiry: options.expiry
|
|
2685
|
+
expiry: options.expiry,
|
|
2686
|
+
nonce: options.authorizeNonce
|
|
2676
2687
|
};
|
|
2677
2688
|
// if (typeof(options.authorize) === 'object') {
|
|
2678
2689
|
// authOptions = { ...authOptions, ...options.authorize }
|
|
@@ -3513,7 +3524,7 @@ class SingleNetworkSequenceProvider extends SequenceProvider {
|
|
|
3513
3524
|
|
|
3514
3525
|
var packageJson = {
|
|
3515
3526
|
name: "@0xsequence/provider",
|
|
3516
|
-
version: "1.2.
|
|
3527
|
+
version: "1.2.3",
|
|
3517
3528
|
description: "provider sub-package for Sequence",
|
|
3518
3529
|
repository: "https://github.com/0xsequence/sequence.js/tree/master/packages/provider",
|
|
3519
3530
|
source: "src/index.ts",
|
|
@@ -8,6 +8,7 @@ var ethers = require('ethers');
|
|
|
8
8
|
var network = require('@0xsequence/network');
|
|
9
9
|
var core = require('@0xsequence/core');
|
|
10
10
|
var auth = require('@0xsequence/auth');
|
|
11
|
+
var abi = require('@0xsequence/abi');
|
|
11
12
|
|
|
12
13
|
function _extends() {
|
|
13
14
|
_extends = Object.assign ? Object.assign.bind() : function (target) {
|
|
@@ -2123,7 +2124,7 @@ function validateTransaction(wallet, transaction) {
|
|
|
2123
2124
|
if (transaction.to.toLowerCase() === wallet.toLowerCase()) {
|
|
2124
2125
|
if (transaction.data) {
|
|
2125
2126
|
const data = ethers.ethers.utils.arrayify(transaction.data);
|
|
2126
|
-
if (data.length >= 4) {
|
|
2127
|
+
if (data.length >= 4 && !isCreateContractCall(data)) {
|
|
2127
2128
|
throw new Error('self calls are forbidden');
|
|
2128
2129
|
}
|
|
2129
2130
|
}
|
|
@@ -2132,6 +2133,15 @@ function validateTransaction(wallet, transaction) {
|
|
|
2132
2133
|
throw new Error('delegate calls are forbidden');
|
|
2133
2134
|
}
|
|
2134
2135
|
}
|
|
2136
|
+
function isCreateContractCall(data) {
|
|
2137
|
+
const walletInterface = new ethers.ethers.utils.Interface(abi.walletContracts.mainModule.abi);
|
|
2138
|
+
try {
|
|
2139
|
+
walletInterface.decodeFunctionData('createContract', data);
|
|
2140
|
+
return true;
|
|
2141
|
+
} catch (_unused) {
|
|
2142
|
+
return false;
|
|
2143
|
+
}
|
|
2144
|
+
}
|
|
2135
2145
|
|
|
2136
2146
|
const SIGNER_READY_TIMEOUT = 10000;
|
|
2137
2147
|
class WalletRequestHandler {
|
|
@@ -2672,7 +2682,8 @@ class WalletRequestHandler {
|
|
|
2672
2682
|
const authOptions = {
|
|
2673
2683
|
app: options.app,
|
|
2674
2684
|
origin: options.origin,
|
|
2675
|
-
expiry: options.expiry
|
|
2685
|
+
expiry: options.expiry,
|
|
2686
|
+
nonce: options.authorizeNonce
|
|
2676
2687
|
};
|
|
2677
2688
|
// if (typeof(options.authorize) === 'object') {
|
|
2678
2689
|
// authOptions = { ...authOptions, ...options.authorize }
|
|
@@ -3513,7 +3524,7 @@ class SingleNetworkSequenceProvider extends SequenceProvider {
|
|
|
3513
3524
|
|
|
3514
3525
|
var packageJson = {
|
|
3515
3526
|
name: "@0xsequence/provider",
|
|
3516
|
-
version: "1.2.
|
|
3527
|
+
version: "1.2.3",
|
|
3517
3528
|
description: "provider sub-package for Sequence",
|
|
3518
3529
|
repository: "https://github.com/0xsequence/sequence.js/tree/master/packages/provider",
|
|
3519
3530
|
source: "src/index.ts",
|
|
@@ -4,6 +4,7 @@ import { ethers, BigNumber } from 'ethers';
|
|
|
4
4
|
import { findSupportedNetwork, ChainId, findNetworkConfig, allNetworks, JsonRpcRouter, loggingProviderMiddleware, exceptionProviderMiddleware, CachedProvider, JsonRpcSender } from '@0xsequence/network';
|
|
5
5
|
import { commons } from '@0xsequence/core';
|
|
6
6
|
import { signAuthorization } from '@0xsequence/auth';
|
|
7
|
+
import { walletContracts } from '@0xsequence/abi';
|
|
7
8
|
|
|
8
9
|
function _extends() {
|
|
9
10
|
_extends = Object.assign ? Object.assign.bind() : function (target) {
|
|
@@ -2119,7 +2120,7 @@ function validateTransaction(wallet, transaction) {
|
|
|
2119
2120
|
if (transaction.to.toLowerCase() === wallet.toLowerCase()) {
|
|
2120
2121
|
if (transaction.data) {
|
|
2121
2122
|
const data = ethers.utils.arrayify(transaction.data);
|
|
2122
|
-
if (data.length >= 4) {
|
|
2123
|
+
if (data.length >= 4 && !isCreateContractCall(data)) {
|
|
2123
2124
|
throw new Error('self calls are forbidden');
|
|
2124
2125
|
}
|
|
2125
2126
|
}
|
|
@@ -2128,6 +2129,15 @@ function validateTransaction(wallet, transaction) {
|
|
|
2128
2129
|
throw new Error('delegate calls are forbidden');
|
|
2129
2130
|
}
|
|
2130
2131
|
}
|
|
2132
|
+
function isCreateContractCall(data) {
|
|
2133
|
+
const walletInterface = new ethers.utils.Interface(walletContracts.mainModule.abi);
|
|
2134
|
+
try {
|
|
2135
|
+
walletInterface.decodeFunctionData('createContract', data);
|
|
2136
|
+
return true;
|
|
2137
|
+
} catch (_unused) {
|
|
2138
|
+
return false;
|
|
2139
|
+
}
|
|
2140
|
+
}
|
|
2131
2141
|
|
|
2132
2142
|
const SIGNER_READY_TIMEOUT = 10000;
|
|
2133
2143
|
class WalletRequestHandler {
|
|
@@ -2668,7 +2678,8 @@ class WalletRequestHandler {
|
|
|
2668
2678
|
const authOptions = {
|
|
2669
2679
|
app: options.app,
|
|
2670
2680
|
origin: options.origin,
|
|
2671
|
-
expiry: options.expiry
|
|
2681
|
+
expiry: options.expiry,
|
|
2682
|
+
nonce: options.authorizeNonce
|
|
2672
2683
|
};
|
|
2673
2684
|
// if (typeof(options.authorize) === 'object') {
|
|
2674
2685
|
// authOptions = { ...authOptions, ...options.authorize }
|
|
@@ -3509,7 +3520,7 @@ class SingleNetworkSequenceProvider extends SequenceProvider {
|
|
|
3509
3520
|
|
|
3510
3521
|
var packageJson = {
|
|
3511
3522
|
name: "@0xsequence/provider",
|
|
3512
|
-
version: "1.2.
|
|
3523
|
+
version: "1.2.3",
|
|
3513
3524
|
description: "provider sub-package for Sequence",
|
|
3514
3525
|
repository: "https://github.com/0xsequence/sequence.js/tree/master/packages/provider",
|
|
3515
3526
|
source: "src/index.ts",
|
|
@@ -115,6 +115,9 @@ export interface ConnectOptions {
|
|
|
115
115
|
expiry?: number;
|
|
116
116
|
/** authorize will perform an ETHAuth eip712 signing and return the proof to the dapp. */
|
|
117
117
|
authorize?: boolean;
|
|
118
|
+
/** authorizeNonce number is an optional number to be passed toe ETHAuth nonce claim for extra
|
|
119
|
+
* challenge and security feature. **/
|
|
120
|
+
authorizeNonce?: number;
|
|
118
121
|
/** authorizeVersion is the version of the SDK that will validate the ETHAuth proof. */
|
|
119
122
|
authorizeVersion?: number;
|
|
120
123
|
/** askForEmail will prompt to give permission to the dapp to access email address */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@0xsequence/provider",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.3",
|
|
4
4
|
"description": "provider sub-package for Sequence",
|
|
5
5
|
"repository": "https://github.com/0xsequence/sequence.js/tree/master/packages/provider",
|
|
6
6
|
"source": "src/index.ts",
|
|
@@ -11,15 +11,15 @@
|
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"eventemitter2": "^6.4.5",
|
|
13
13
|
"webextension-polyfill": "^0.10.0",
|
|
14
|
-
"@0xsequence/abi": "1.2.
|
|
15
|
-
"@0xsequence/
|
|
16
|
-
"@0xsequence/auth": "1.2.
|
|
17
|
-
"@0xsequence/
|
|
18
|
-
"@0xsequence/
|
|
19
|
-
"@0xsequence/network": "1.2.
|
|
20
|
-
"@0xsequence/relayer": "1.2.
|
|
21
|
-
"@0xsequence/utils": "1.2.
|
|
22
|
-
"@0xsequence/wallet": "1.2.
|
|
14
|
+
"@0xsequence/abi": "1.2.3",
|
|
15
|
+
"@0xsequence/account": "1.2.3",
|
|
16
|
+
"@0xsequence/auth": "1.2.3",
|
|
17
|
+
"@0xsequence/migration": "1.2.3",
|
|
18
|
+
"@0xsequence/core": "1.2.3",
|
|
19
|
+
"@0xsequence/network": "1.2.3",
|
|
20
|
+
"@0xsequence/relayer": "1.2.3",
|
|
21
|
+
"@0xsequence/utils": "1.2.3",
|
|
22
|
+
"@0xsequence/wallet": "1.2.3"
|
|
23
23
|
},
|
|
24
24
|
"peerDependencies": {
|
|
25
25
|
"ethers": ">=5.5 < 6"
|
package/src/transactions.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { walletContracts } from '@0xsequence/abi'
|
|
1
2
|
import { commons } from '@0xsequence/core'
|
|
2
3
|
import { ethers } from 'ethers'
|
|
3
4
|
|
|
@@ -11,7 +12,7 @@ function validateTransaction(wallet: string, transaction: commons.transaction.Tr
|
|
|
11
12
|
if (transaction.to.toLowerCase() === wallet.toLowerCase()) {
|
|
12
13
|
if (transaction.data) {
|
|
13
14
|
const data = ethers.utils.arrayify(transaction.data)
|
|
14
|
-
if (data.length >= 4) {
|
|
15
|
+
if (data.length >= 4 && !isCreateContractCall(data)) {
|
|
15
16
|
throw new Error('self calls are forbidden')
|
|
16
17
|
}
|
|
17
18
|
}
|
|
@@ -21,3 +22,13 @@ function validateTransaction(wallet: string, transaction: commons.transaction.Tr
|
|
|
21
22
|
throw new Error('delegate calls are forbidden')
|
|
22
23
|
}
|
|
23
24
|
}
|
|
25
|
+
|
|
26
|
+
function isCreateContractCall(data: ethers.BytesLike): boolean {
|
|
27
|
+
const walletInterface = new ethers.utils.Interface(walletContracts.mainModule.abi)
|
|
28
|
+
try {
|
|
29
|
+
walletInterface.decodeFunctionData('createContract', data)
|
|
30
|
+
return true
|
|
31
|
+
} catch {
|
|
32
|
+
return false
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -159,7 +159,8 @@ export class WalletRequestHandler implements ExternalProvider, JsonRpcHandler, P
|
|
|
159
159
|
const authOptions: AuthorizationOptions = {
|
|
160
160
|
app: options.app,
|
|
161
161
|
origin: options.origin,
|
|
162
|
-
expiry: options.expiry
|
|
162
|
+
expiry: options.expiry,
|
|
163
|
+
nonce: options.authorizeNonce
|
|
163
164
|
}
|
|
164
165
|
// if (typeof(options.authorize) === 'object') {
|
|
165
166
|
// authOptions = { ...authOptions, ...options.authorize }
|
package/src/types.ts
CHANGED
|
@@ -171,6 +171,10 @@ export interface ConnectOptions {
|
|
|
171
171
|
/** authorize will perform an ETHAuth eip712 signing and return the proof to the dapp. */
|
|
172
172
|
authorize?: boolean
|
|
173
173
|
|
|
174
|
+
/** authorizeNonce number is an optional number to be passed toe ETHAuth nonce claim for extra
|
|
175
|
+
* challenge and security feature. **/
|
|
176
|
+
authorizeNonce?: number
|
|
177
|
+
|
|
174
178
|
/** authorizeVersion is the version of the SDK that will validate the ETHAuth proof. */
|
|
175
179
|
authorizeVersion?: number
|
|
176
180
|
|