@0xsequence/wallet-core 3.0.0-beta.1 → 3.0.0-beta.10
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/.turbo/turbo-build.log +1 -1
- package/CHANGELOG.md +90 -0
- package/dist/signers/pk/encrypted.d.ts +2 -2
- package/dist/signers/pk/encrypted.d.ts.map +1 -1
- package/dist/state/local/index.js +1 -1
- package/dist/state/sequence/index.js +12 -8
- package/package.json +13 -13
- package/src/signers/pk/encrypted.ts +2 -2
- package/src/state/local/index.ts +1 -1
- package/src/state/sequence/index.ts +12 -7
- package/src/utils/session/permission-builder.ts +2 -2
- package/test/constants.ts +0 -2
- package/test/session-manager.test.ts +24 -7
- package/vitest.config.ts +0 -9
package/.turbo/turbo-build.log
CHANGED
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,95 @@
|
|
|
1
1
|
# @0xsequence/wallet-core
|
|
2
2
|
|
|
3
|
+
## 3.0.0-beta.10
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- dapp-client updates
|
|
8
|
+
- Updated dependencies
|
|
9
|
+
- @0xsequence/guard@3.0.0-beta.10
|
|
10
|
+
- @0xsequence/relayer@3.0.0-beta.10
|
|
11
|
+
- @0xsequence/wallet-primitives@3.0.0-beta.10
|
|
12
|
+
|
|
13
|
+
## 3.0.0-beta.9
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- dapp client updates for EOA login
|
|
18
|
+
- Updated dependencies
|
|
19
|
+
- @0xsequence/guard@3.0.0-beta.9
|
|
20
|
+
- @0xsequence/relayer@3.0.0-beta.9
|
|
21
|
+
- @0xsequence/wallet-primitives@3.0.0-beta.9
|
|
22
|
+
|
|
23
|
+
## 3.0.0-beta.8
|
|
24
|
+
|
|
25
|
+
### Patch Changes
|
|
26
|
+
|
|
27
|
+
- Apple auth fixes
|
|
28
|
+
- Updated dependencies
|
|
29
|
+
- @0xsequence/guard@3.0.0-beta.8
|
|
30
|
+
- @0xsequence/relayer@3.0.0-beta.8
|
|
31
|
+
- @0xsequence/wallet-primitives@3.0.0-beta.8
|
|
32
|
+
|
|
33
|
+
## 3.0.0-beta.7
|
|
34
|
+
|
|
35
|
+
### Patch Changes
|
|
36
|
+
|
|
37
|
+
- Apple auth fix
|
|
38
|
+
- Updated dependencies
|
|
39
|
+
- @0xsequence/guard@3.0.0-beta.7
|
|
40
|
+
- @0xsequence/relayer@3.0.0-beta.7
|
|
41
|
+
- @0xsequence/wallet-primitives@3.0.0-beta.7
|
|
42
|
+
|
|
43
|
+
## 3.0.0-beta.6
|
|
44
|
+
|
|
45
|
+
### Patch Changes
|
|
46
|
+
|
|
47
|
+
- Fix signer 404 error, minor fixes
|
|
48
|
+
- Updated dependencies
|
|
49
|
+
- @0xsequence/guard@3.0.0-beta.6
|
|
50
|
+
- @0xsequence/relayer@3.0.0-beta.6
|
|
51
|
+
- @0xsequence/wallet-primitives@3.0.0-beta.6
|
|
52
|
+
|
|
53
|
+
## 3.0.0-beta.5
|
|
54
|
+
|
|
55
|
+
### Patch Changes
|
|
56
|
+
|
|
57
|
+
- Beta release for v3
|
|
58
|
+
- Updated dependencies
|
|
59
|
+
- @0xsequence/guard@3.0.0-beta.5
|
|
60
|
+
- @0xsequence/relayer@3.0.0-beta.5
|
|
61
|
+
- @0xsequence/wallet-primitives@3.0.0-beta.5
|
|
62
|
+
|
|
63
|
+
## 3.0.0-beta.4
|
|
64
|
+
|
|
65
|
+
### Patch Changes
|
|
66
|
+
|
|
67
|
+
- RC5 upgrade
|
|
68
|
+
- Updated dependencies
|
|
69
|
+
- @0xsequence/guard@3.0.0-beta.4
|
|
70
|
+
- @0xsequence/relayer@3.0.0-beta.4
|
|
71
|
+
- @0xsequence/wallet-primitives@3.0.0-beta.4
|
|
72
|
+
|
|
73
|
+
## 3.0.0-beta.3
|
|
74
|
+
|
|
75
|
+
### Patch Changes
|
|
76
|
+
|
|
77
|
+
- 3.0.0-beta.3 with fixes
|
|
78
|
+
- Updated dependencies
|
|
79
|
+
- @0xsequence/guard@3.0.0-beta.3
|
|
80
|
+
- @0xsequence/relayer@3.0.0-beta.3
|
|
81
|
+
- @0xsequence/wallet-primitives@3.0.0-beta.3
|
|
82
|
+
|
|
83
|
+
## 3.0.0-beta.2
|
|
84
|
+
|
|
85
|
+
### Patch Changes
|
|
86
|
+
|
|
87
|
+
- 3.0.0-beta.2 with identity instrument updates
|
|
88
|
+
- Updated dependencies
|
|
89
|
+
- @0xsequence/guard@3.0.0-beta.2
|
|
90
|
+
- @0xsequence/relayer@3.0.0-beta.2
|
|
91
|
+
- @0xsequence/wallet-primitives@3.0.0-beta.2
|
|
92
|
+
|
|
3
93
|
## 3.0.0-beta.1
|
|
4
94
|
|
|
5
95
|
### Patch Changes
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Address, PublicKey, Bytes } from 'ox';
|
|
2
2
|
import { PkStore } from './index.js';
|
|
3
3
|
export interface EncryptedData {
|
|
4
|
-
iv:
|
|
5
|
-
data:
|
|
4
|
+
iv: BufferSource;
|
|
5
|
+
data: BufferSource;
|
|
6
6
|
keyPointer: string;
|
|
7
7
|
address: Address.Address;
|
|
8
8
|
publicKey: PublicKey.PublicKey;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"encrypted.d.ts","sourceRoot":"","sources":["../../../src/signers/pk/encrypted.ts"],"names":[],"mappings":"AAAA,OAAO,EAAO,OAAO,EAAE,SAAS,EAAa,KAAK,EAAE,MAAM,IAAI,CAAA;AAC9D,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AAEpC,MAAM,WAAW,aAAa;IAC5B,EAAE,EAAE,
|
|
1
|
+
{"version":3,"file":"encrypted.d.ts","sourceRoot":"","sources":["../../../src/signers/pk/encrypted.ts"],"names":[],"mappings":"AAAA,OAAO,EAAO,OAAO,EAAE,SAAS,EAAa,KAAK,EAAE,MAAM,IAAI,CAAA;AA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E,CAAC;CAc1F"}
|
|
@@ -5,7 +5,7 @@ import { normalizeAddressKeys } from '../utils.js';
|
|
|
5
5
|
export class Provider {
|
|
6
6
|
store;
|
|
7
7
|
extensions;
|
|
8
|
-
constructor(store = new MemoryStore(), extensions = Extensions.
|
|
8
|
+
constructor(store = new MemoryStore(), extensions = Extensions.Rc5) {
|
|
9
9
|
this.store = store;
|
|
10
10
|
this.extensions = extensions;
|
|
11
11
|
}
|
|
@@ -273,14 +273,18 @@ const passkeySigners = [
|
|
|
273
273
|
Extensions.Dev2.passkeys,
|
|
274
274
|
Extensions.Rc3.passkeys,
|
|
275
275
|
Extensions.Rc4.passkeys,
|
|
276
|
+
Extensions.Rc5.passkeys,
|
|
276
277
|
].map(Address.checksum);
|
|
277
278
|
const recoverSapientSignatureCompactSignature = 'function recoverSapientSignatureCompact(bytes32 _digest, bytes _signature) view returns (bytes32)';
|
|
278
279
|
const recoverSapientSignatureCompactFunction = AbiFunction.from(recoverSapientSignatureCompactSignature);
|
|
279
280
|
class PasskeySignatureValidator {
|
|
280
|
-
request = ((
|
|
281
|
-
switch (method) {
|
|
281
|
+
request = (async (request) => {
|
|
282
|
+
switch (request.method) {
|
|
282
283
|
case 'eth_call':
|
|
283
|
-
|
|
284
|
+
if (!request.params || !Array.isArray(request.params) || request.params.length === 0) {
|
|
285
|
+
throw new Error('eth_call requires transaction parameters');
|
|
286
|
+
}
|
|
287
|
+
const transaction = request.params[0];
|
|
284
288
|
if (!transaction.data?.startsWith(AbiFunction.getSelector(recoverSapientSignatureCompactFunction))) {
|
|
285
289
|
throw new Error(`unknown selector ${transaction.data?.slice(0, 10)}, expected selector ${AbiFunction.getSelector(recoverSapientSignatureCompactFunction)} for ${recoverSapientSignatureCompactSignature}`);
|
|
286
290
|
}
|
|
@@ -296,15 +300,15 @@ class PasskeySignatureValidator {
|
|
|
296
300
|
throw new Error(`invalid passkey signature ${signature} for digest ${digest}`);
|
|
297
301
|
}
|
|
298
302
|
default:
|
|
299
|
-
throw new Error(`method ${method} not implemented`);
|
|
303
|
+
throw new Error(`method ${request.method} not implemented`);
|
|
300
304
|
}
|
|
301
305
|
});
|
|
302
|
-
on(event) {
|
|
306
|
+
on = (event) => {
|
|
303
307
|
throw new Error(`unable to listen for ${event}: not implemented`);
|
|
304
|
-
}
|
|
305
|
-
removeListener(event) {
|
|
308
|
+
};
|
|
309
|
+
removeListener = (event) => {
|
|
306
310
|
throw new Error(`unable to remove listener for ${event}: not implemented`);
|
|
307
|
-
}
|
|
311
|
+
};
|
|
308
312
|
}
|
|
309
313
|
const passkeySignatureValidator = new PasskeySignatureValidator();
|
|
310
314
|
function getServiceConfig(config) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@0xsequence/wallet-core",
|
|
3
|
-
"version": "3.0.0-beta.
|
|
3
|
+
"version": "3.0.0-beta.10",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"publishConfig": {
|
|
@@ -14,21 +14,21 @@
|
|
|
14
14
|
}
|
|
15
15
|
},
|
|
16
16
|
"devDependencies": {
|
|
17
|
-
"@types/node": "^
|
|
18
|
-
"@vitest/coverage-v8": "^
|
|
19
|
-
"dotenv": "^
|
|
20
|
-
"fake-indexeddb": "^6.
|
|
21
|
-
"typescript": "^5.
|
|
22
|
-
"vitest": "^
|
|
23
|
-
"@repo/typescript-config": "^0.0.
|
|
17
|
+
"@types/node": "^25.0.2",
|
|
18
|
+
"@vitest/coverage-v8": "^4.0.15",
|
|
19
|
+
"dotenv": "^17.2.3",
|
|
20
|
+
"fake-indexeddb": "^6.2.5",
|
|
21
|
+
"typescript": "^5.9.3",
|
|
22
|
+
"vitest": "^4.0.15",
|
|
23
|
+
"@repo/typescript-config": "^0.0.1-beta.1"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"mipd": "^0.0.7",
|
|
27
|
-
"ox": "^0.
|
|
28
|
-
"viem": "^2.
|
|
29
|
-
"@0xsequence/
|
|
30
|
-
"@0xsequence/
|
|
31
|
-
"@0xsequence/guard": "^3.0.0-beta.
|
|
27
|
+
"ox": "^0.9.17",
|
|
28
|
+
"viem": "^2.40.3",
|
|
29
|
+
"@0xsequence/wallet-primitives": "^3.0.0-beta.10",
|
|
30
|
+
"@0xsequence/relayer": "^3.0.0-beta.10",
|
|
31
|
+
"@0xsequence/guard": "^3.0.0-beta.10"
|
|
32
32
|
},
|
|
33
33
|
"scripts": {
|
|
34
34
|
"build": "tsc",
|
|
@@ -2,8 +2,8 @@ import { Hex, Address, PublicKey, Secp256k1, Bytes } from 'ox'
|
|
|
2
2
|
import { PkStore } from './index.js'
|
|
3
3
|
|
|
4
4
|
export interface EncryptedData {
|
|
5
|
-
iv:
|
|
6
|
-
data:
|
|
5
|
+
iv: BufferSource
|
|
6
|
+
data: BufferSource
|
|
7
7
|
keyPointer: string
|
|
8
8
|
address: Address.Address
|
|
9
9
|
publicKey: PublicKey.PublicKey
|
package/src/state/local/index.ts
CHANGED
|
@@ -66,7 +66,7 @@ export interface Store {
|
|
|
66
66
|
export class Provider implements ProviderInterface {
|
|
67
67
|
constructor(
|
|
68
68
|
private readonly store: Store = new MemoryStore(),
|
|
69
|
-
public readonly extensions: Extensions.Extensions = Extensions.
|
|
69
|
+
public readonly extensions: Extensions.Extensions = Extensions.Rc5,
|
|
70
70
|
) {}
|
|
71
71
|
|
|
72
72
|
getConfiguration(imageHash: Hex.Hex): Promise<Config.Config | undefined> {
|
|
@@ -369,6 +369,7 @@ const passkeySigners = [
|
|
|
369
369
|
Extensions.Dev2.passkeys,
|
|
370
370
|
Extensions.Rc3.passkeys,
|
|
371
371
|
Extensions.Rc4.passkeys,
|
|
372
|
+
Extensions.Rc5.passkeys,
|
|
372
373
|
].map(Address.checksum)
|
|
373
374
|
|
|
374
375
|
const recoverSapientSignatureCompactSignature =
|
|
@@ -377,10 +378,14 @@ const recoverSapientSignatureCompactSignature =
|
|
|
377
378
|
const recoverSapientSignatureCompactFunction = AbiFunction.from(recoverSapientSignatureCompactSignature)
|
|
378
379
|
|
|
379
380
|
class PasskeySignatureValidator implements oxProvider.Provider {
|
|
380
|
-
request: oxProvider.Provider['request'] = ((
|
|
381
|
-
switch (method) {
|
|
381
|
+
request: oxProvider.Provider['request'] = (async (request) => {
|
|
382
|
+
switch (request.method) {
|
|
382
383
|
case 'eth_call':
|
|
383
|
-
|
|
384
|
+
if (!request.params || !Array.isArray(request.params) || request.params.length === 0) {
|
|
385
|
+
throw new Error('eth_call requires transaction parameters')
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
const transaction: TransactionRequest.Rpc = request.params[0]
|
|
384
389
|
|
|
385
390
|
if (!transaction.data?.startsWith(AbiFunction.getSelector(recoverSapientSignatureCompactFunction))) {
|
|
386
391
|
throw new Error(
|
|
@@ -403,15 +408,15 @@ class PasskeySignatureValidator implements oxProvider.Provider {
|
|
|
403
408
|
}
|
|
404
409
|
|
|
405
410
|
default:
|
|
406
|
-
throw new Error(`method ${method} not implemented`)
|
|
411
|
+
throw new Error(`method ${request.method} not implemented`)
|
|
407
412
|
}
|
|
408
|
-
}) as
|
|
413
|
+
}) as oxProvider.Provider['request']
|
|
409
414
|
|
|
410
|
-
on(event: string) {
|
|
415
|
+
on: oxProvider.Provider['on'] = (event: string) => {
|
|
411
416
|
throw new Error(`unable to listen for ${event}: not implemented`)
|
|
412
417
|
}
|
|
413
418
|
|
|
414
|
-
removeListener(event: string) {
|
|
419
|
+
removeListener: oxProvider.Provider['removeListener'] = (event: string) => {
|
|
415
420
|
throw new Error(`unable to remove listener for ${event}: not implemented`)
|
|
416
421
|
}
|
|
417
422
|
}
|
|
@@ -59,8 +59,8 @@ export class PermissionBuilder {
|
|
|
59
59
|
throw new Error(`cannot call exactCalldata() after calling allowAll() or adding rules`)
|
|
60
60
|
}
|
|
61
61
|
for (let offset = 0; offset < calldata.length; offset += 32) {
|
|
62
|
-
let value = calldata.slice(offset, offset + 32)
|
|
63
|
-
let mask = Permission.MASK.BYTES32
|
|
62
|
+
let value: Bytes.Bytes = calldata.slice(offset, offset + 32)
|
|
63
|
+
let mask: Bytes.Bytes = Permission.MASK.BYTES32
|
|
64
64
|
if (value.length < 32) {
|
|
65
65
|
mask = Bytes.fromHex(`0x${'ff'.repeat(value.length)}${'00'.repeat(32 - value.length)}`)
|
|
66
66
|
value = Bytes.padRight(value, 32)
|
package/test/constants.ts
CHANGED
|
@@ -17,5 +17,3 @@ export const USDC_ADDRESS: Address.Address = '0xaf88d065e77c8cc2239327c5edb3a432
|
|
|
17
17
|
|
|
18
18
|
// Environment variables
|
|
19
19
|
export const LOCAL_RPC_URL = process.env.LOCAL_RPC_URL || 'http://localhost:8545'
|
|
20
|
-
export const { RPC_URL, PRIVATE_KEY } = process.env
|
|
21
|
-
export const CAN_RUN_LIVE = !!RPC_URL && !!PRIVATE_KEY
|
|
@@ -1,20 +1,17 @@
|
|
|
1
|
+
import { Extensions } from '@0xsequence/wallet-primitives'
|
|
1
2
|
import { AbiEvent, AbiFunction, Address, Bytes, Hex, Provider, RpcTransport, Secp256k1 } from 'ox'
|
|
2
3
|
import { describe, expect, it } from 'vitest'
|
|
3
|
-
|
|
4
4
|
import { Attestation, GenericTree, Payload, Permission, SessionConfig } from '../../primitives/src/index.js'
|
|
5
5
|
import { Envelope, Signers, State, Utils, Wallet } from '../src/index.js'
|
|
6
|
-
|
|
6
|
+
import { ExplicitSessionConfig } from '../src/utils/session/types.js'
|
|
7
7
|
import {
|
|
8
|
-
EMITTER_FUNCTIONS,
|
|
9
8
|
EMITTER_ADDRESS1,
|
|
10
9
|
EMITTER_ADDRESS2,
|
|
11
10
|
EMITTER_EVENT_TOPICS,
|
|
11
|
+
EMITTER_FUNCTIONS,
|
|
12
12
|
LOCAL_RPC_URL,
|
|
13
13
|
USDC_ADDRESS,
|
|
14
14
|
} from './constants'
|
|
15
|
-
import { Extensions } from '@0xsequence/wallet-primitives'
|
|
16
|
-
import { ExplicitSessionConfig } from '../src/utils/session/types.js'
|
|
17
|
-
|
|
18
15
|
const { PermissionBuilder, ERC20PermissionBuilder } = Utils
|
|
19
16
|
|
|
20
17
|
function randomAddress(): Address.Address {
|
|
@@ -38,6 +35,10 @@ const ALL_EXTENSIONS = [
|
|
|
38
35
|
name: 'Rc4',
|
|
39
36
|
...Extensions.Rc4,
|
|
40
37
|
},
|
|
38
|
+
{
|
|
39
|
+
name: 'Rc5',
|
|
40
|
+
...Extensions.Rc5,
|
|
41
|
+
},
|
|
41
42
|
]
|
|
42
43
|
|
|
43
44
|
// Handle the increment call being first or last depending on the session manager version
|
|
@@ -605,10 +606,26 @@ for (const extension of ALL_EXTENSIONS) {
|
|
|
605
606
|
transaction: { to: Address.Address; data: Hex.Hex },
|
|
606
607
|
expectedEventTopic?: Hex.Hex,
|
|
607
608
|
) => {
|
|
609
|
+
// Generate and use a random sender address to prevent race conditions
|
|
610
|
+
const senderAddress = Address.fromPublicKey(Secp256k1.getPublicKey({ privateKey: Secp256k1.randomPrivateKey() }))
|
|
611
|
+
await provider.request({
|
|
612
|
+
method: 'anvil_setBalance',
|
|
613
|
+
params: [senderAddress, Hex.fromNumber(1000000000000000000n)],
|
|
614
|
+
})
|
|
615
|
+
await provider.request({
|
|
616
|
+
method: 'anvil_impersonateAccount',
|
|
617
|
+
params: [senderAddress],
|
|
618
|
+
})
|
|
619
|
+
|
|
608
620
|
console.log('Simulating transaction', transaction)
|
|
609
621
|
const txHash = await provider.request({
|
|
610
622
|
method: 'eth_sendTransaction',
|
|
611
|
-
params: [
|
|
623
|
+
params: [
|
|
624
|
+
{
|
|
625
|
+
...transaction,
|
|
626
|
+
from: senderAddress,
|
|
627
|
+
},
|
|
628
|
+
],
|
|
612
629
|
})
|
|
613
630
|
console.log('Transaction hash:', txHash)
|
|
614
631
|
|