tempo.ts 0.11.1 → 0.12.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.
- package/CHANGELOG.md +67 -4
- package/README.md +3 -34
- package/dist/server/Handler.d.ts +14 -14
- package/dist/server/Handler.d.ts.map +1 -1
- package/dist/server/Handler.js +16 -17
- package/dist/server/Handler.js.map +1 -1
- package/dist/wagmi/Actions/amm.d.ts +51 -51
- package/dist/wagmi/Actions/amm.d.ts.map +1 -1
- package/dist/wagmi/Actions/amm.js +37 -37
- package/dist/wagmi/Actions/amm.js.map +1 -1
- package/dist/wagmi/Actions/dex.d.ts +129 -129
- package/dist/wagmi/Actions/dex.d.ts.map +1 -1
- package/dist/wagmi/Actions/dex.js +73 -73
- package/dist/wagmi/Actions/dex.js.map +1 -1
- package/dist/wagmi/Actions/faucet.d.ts +9 -9
- package/dist/wagmi/Actions/faucet.d.ts.map +1 -1
- package/dist/wagmi/Actions/faucet.js +7 -7
- package/dist/wagmi/Actions/faucet.js.map +1 -1
- package/dist/wagmi/Actions/fee.d.ts +17 -17
- package/dist/wagmi/Actions/fee.d.ts.map +1 -1
- package/dist/wagmi/Actions/fee.js +10 -10
- package/dist/wagmi/Actions/fee.js.map +1 -1
- package/dist/wagmi/Actions/nonce.d.ts +9 -79
- package/dist/wagmi/Actions/nonce.d.ts.map +1 -1
- package/dist/wagmi/Actions/nonce.js +7 -89
- package/dist/wagmi/Actions/nonce.js.map +1 -1
- package/dist/wagmi/Actions/policy.d.ts +69 -70
- package/dist/wagmi/Actions/policy.d.ts.map +1 -1
- package/dist/wagmi/Actions/policy.js +43 -43
- package/dist/wagmi/Actions/policy.js.map +1 -1
- package/dist/wagmi/Actions/reward.d.ts +51 -51
- package/dist/wagmi/Actions/reward.d.ts.map +1 -1
- package/dist/wagmi/Actions/reward.js +31 -31
- package/dist/wagmi/Actions/reward.js.map +1 -1
- package/dist/wagmi/Actions/token.d.ts +238 -238
- package/dist/wagmi/Actions/token.d.ts.map +1 -1
- package/dist/wagmi/Actions/token.js +136 -136
- package/dist/wagmi/Actions/token.js.map +1 -1
- package/dist/wagmi/Connector.d.ts +2 -1
- package/dist/wagmi/Connector.d.ts.map +1 -1
- package/dist/wagmi/Connector.js +83 -22
- package/dist/wagmi/Connector.js.map +1 -1
- package/dist/wagmi/Hooks/nonce.d.ts +1 -52
- package/dist/wagmi/Hooks/nonce.d.ts.map +1 -1
- package/dist/wagmi/Hooks/nonce.js +1 -70
- package/dist/wagmi/Hooks/nonce.js.map +1 -1
- package/dist/wagmi/Hooks/policy.d.ts +0 -1
- package/dist/wagmi/Hooks/policy.d.ts.map +1 -1
- package/dist/wagmi/Hooks/policy.js.map +1 -1
- package/dist/wagmi/KeyManager.d.ts +6 -3
- package/dist/wagmi/KeyManager.d.ts.map +1 -1
- package/dist/wagmi/KeyManager.js +9 -4
- package/dist/wagmi/KeyManager.js.map +1 -1
- package/package.json +3 -13
- package/src/server/Handler.test.ts +2 -2
- package/src/server/Handler.ts +16 -17
- package/src/wagmi/Actions/amm.ts +63 -63
- package/src/wagmi/Actions/dex.test.ts +1 -1
- package/src/wagmi/Actions/dex.ts +153 -153
- package/src/wagmi/Actions/faucet.ts +11 -11
- package/src/wagmi/Actions/fee.ts +20 -20
- package/src/wagmi/Actions/nonce.test.ts +1 -64
- package/src/wagmi/Actions/nonce.ts +10 -142
- package/src/wagmi/Actions/policy.ts +83 -85
- package/src/wagmi/Actions/reward.ts +64 -61
- package/src/wagmi/Actions/token.ts +287 -283
- package/src/wagmi/Connector.ts +105 -31
- package/src/wagmi/Hooks/dex.test.ts +1 -1
- package/src/wagmi/Hooks/fee.test.ts +0 -6
- package/src/wagmi/Hooks/nonce.test.ts +1 -66
- package/src/wagmi/Hooks/nonce.ts +1 -114
- package/src/wagmi/Hooks/policy.ts +0 -2
- package/src/wagmi/KeyManager.ts +18 -5
- package/dist/chains.d.ts +0 -73
- package/dist/chains.d.ts.map +0 -1
- package/dist/chains.js +0 -51
- package/dist/chains.js.map +0 -1
- package/dist/viem/Abis.d.ts +0 -2649
- package/dist/viem/Abis.d.ts.map +0 -1
- package/dist/viem/Abis.js +0 -1677
- package/dist/viem/Abis.js.map +0 -1
- package/dist/viem/Account.d.ts +0 -244
- package/dist/viem/Account.d.ts.map +0 -1
- package/dist/viem/Account.js +0 -382
- package/dist/viem/Account.js.map +0 -1
- package/dist/viem/Actions/account.d.ts +0 -40
- package/dist/viem/Actions/account.d.ts.map +0 -1
- package/dist/viem/Actions/account.js +0 -86
- package/dist/viem/Actions/account.js.map +0 -1
- package/dist/viem/Actions/amm.d.ts +0 -1991
- package/dist/viem/Actions/amm.d.ts.map +0 -1
- package/dist/viem/Actions/amm.js +0 -814
- package/dist/viem/Actions/amm.js.map +0 -1
- package/dist/viem/Actions/dex.d.ts +0 -3900
- package/dist/viem/Actions/dex.d.ts.map +0 -1
- package/dist/viem/Actions/dex.js +0 -1414
- package/dist/viem/Actions/dex.js.map +0 -1
- package/dist/viem/Actions/faucet.d.ts +0 -69
- package/dist/viem/Actions/faucet.d.ts.map +0 -1
- package/dist/viem/Actions/faucet.js +0 -73
- package/dist/viem/Actions/faucet.js.map +0 -1
- package/dist/viem/Actions/fee.d.ts +0 -360
- package/dist/viem/Actions/fee.d.ts.map +0 -1
- package/dist/viem/Actions/fee.js +0 -237
- package/dist/viem/Actions/fee.js.map +0 -1
- package/dist/viem/Actions/index.d.ts +0 -10
- package/dist/viem/Actions/index.d.ts.map +0 -1
- package/dist/viem/Actions/index.js +0 -10
- package/dist/viem/Actions/index.js.map +0 -1
- package/dist/viem/Actions/nonce.d.ts +0 -257
- package/dist/viem/Actions/nonce.d.ts.map +0 -1
- package/dist/viem/Actions/nonce.js +0 -228
- package/dist/viem/Actions/nonce.js.map +0 -1
- package/dist/viem/Actions/policy.d.ts +0 -1680
- package/dist/viem/Actions/policy.d.ts.map +0 -1
- package/dist/viem/Actions/policy.js +0 -875
- package/dist/viem/Actions/policy.js.map +0 -1
- package/dist/viem/Actions/reward.d.ts +0 -2422
- package/dist/viem/Actions/reward.d.ts.map +0 -1
- package/dist/viem/Actions/reward.js +0 -651
- package/dist/viem/Actions/reward.js.map +0 -1
- package/dist/viem/Actions/token.d.ts +0 -16007
- package/dist/viem/Actions/token.d.ts.map +0 -1
- package/dist/viem/Actions/token.js +0 -2936
- package/dist/viem/Actions/token.js.map +0 -1
- package/dist/viem/Addresses.d.ts +0 -9
- package/dist/viem/Addresses.d.ts.map +0 -1
- package/dist/viem/Addresses.js +0 -9
- package/dist/viem/Addresses.js.map +0 -1
- package/dist/viem/Chain.d.ts +0 -451
- package/dist/viem/Chain.d.ts.map +0 -1
- package/dist/viem/Chain.js +0 -96
- package/dist/viem/Chain.js.map +0 -1
- package/dist/viem/Decorator.d.ts +0 -2783
- package/dist/viem/Decorator.d.ts.map +0 -1
- package/dist/viem/Decorator.js +0 -137
- package/dist/viem/Decorator.js.map +0 -1
- package/dist/viem/Formatters.d.ts +0 -10
- package/dist/viem/Formatters.d.ts.map +0 -1
- package/dist/viem/Formatters.js +0 -104
- package/dist/viem/Formatters.js.map +0 -1
- package/dist/viem/P256.d.ts +0 -2
- package/dist/viem/P256.d.ts.map +0 -1
- package/dist/viem/P256.js +0 -2
- package/dist/viem/P256.js.map +0 -1
- package/dist/viem/Secp256k1.d.ts +0 -2
- package/dist/viem/Secp256k1.d.ts.map +0 -1
- package/dist/viem/Secp256k1.js +0 -2
- package/dist/viem/Secp256k1.js.map +0 -1
- package/dist/viem/Storage.d.ts +0 -24
- package/dist/viem/Storage.d.ts.map +0 -1
- package/dist/viem/Storage.js +0 -68
- package/dist/viem/Storage.js.map +0 -1
- package/dist/viem/TokenIds.d.ts +0 -2
- package/dist/viem/TokenIds.d.ts.map +0 -1
- package/dist/viem/TokenIds.js +0 -2
- package/dist/viem/TokenIds.js.map +0 -1
- package/dist/viem/Transaction.d.ts +0 -76
- package/dist/viem/Transaction.d.ts.map +0 -1
- package/dist/viem/Transaction.js +0 -176
- package/dist/viem/Transaction.js.map +0 -1
- package/dist/viem/Transport.d.ts +0 -33
- package/dist/viem/Transport.d.ts.map +0 -1
- package/dist/viem/Transport.js +0 -138
- package/dist/viem/Transport.js.map +0 -1
- package/dist/viem/WebAuthnP256.d.ts +0 -82
- package/dist/viem/WebAuthnP256.d.ts.map +0 -1
- package/dist/viem/WebAuthnP256.js +0 -97
- package/dist/viem/WebAuthnP256.js.map +0 -1
- package/dist/viem/WebCryptoP256.d.ts +0 -2
- package/dist/viem/WebCryptoP256.d.ts.map +0 -1
- package/dist/viem/WebCryptoP256.js +0 -2
- package/dist/viem/WebCryptoP256.js.map +0 -1
- package/dist/viem/index.d.ts +0 -26
- package/dist/viem/index.d.ts.map +0 -1
- package/dist/viem/index.js +0 -17
- package/dist/viem/index.js.map +0 -1
- package/dist/viem/internal/types.d.ts +0 -20
- package/dist/viem/internal/types.d.ts.map +0 -1
- package/dist/viem/internal/types.js +0 -2
- package/dist/viem/internal/types.js.map +0 -1
- package/dist/viem/internal/utils.d.ts +0 -14
- package/dist/viem/internal/utils.d.ts.map +0 -1
- package/dist/viem/internal/utils.js +0 -33
- package/dist/viem/internal/utils.js.map +0 -1
- package/src/chains.ts +0 -54
- package/src/viem/Abis.ts +0 -1688
- package/src/viem/Account.test.ts +0 -444
- package/src/viem/Account.ts +0 -601
- package/src/viem/Actions/account.test.ts +0 -414
- package/src/viem/Actions/account.ts +0 -106
- package/src/viem/Actions/amm.test.ts +0 -381
- package/src/viem/Actions/amm.ts +0 -1227
- package/src/viem/Actions/dex.test.ts +0 -1549
- package/src/viem/Actions/dex.ts +0 -2150
- package/src/viem/Actions/faucet.ts +0 -121
- package/src/viem/Actions/fee.test.ts +0 -259
- package/src/viem/Actions/fee.ts +0 -372
- package/src/viem/Actions/index.ts +0 -9
- package/src/viem/Actions/nonce.test.ts +0 -206
- package/src/viem/Actions/nonce.ts +0 -347
- package/src/viem/Actions/policy.test.ts +0 -534
- package/src/viem/Actions/policy.ts +0 -1335
- package/src/viem/Actions/reward.test.ts +0 -434
- package/src/viem/Actions/reward.ts +0 -944
- package/src/viem/Actions/token.test.ts +0 -3029
- package/src/viem/Actions/token.ts +0 -4458
- package/src/viem/Addresses.ts +0 -9
- package/src/viem/Chain.bench-d.ts +0 -12
- package/src/viem/Chain.test.ts +0 -168
- package/src/viem/Chain.ts +0 -157
- package/src/viem/Decorator.bench-d.ts +0 -11
- package/src/viem/Decorator.test.ts +0 -39
- package/src/viem/Decorator.ts +0 -3179
- package/src/viem/Formatters.ts +0 -164
- package/src/viem/P256.ts +0 -1
- package/src/viem/Secp256k1.ts +0 -1
- package/src/viem/Storage.ts +0 -110
- package/src/viem/TokenIds.ts +0 -1
- package/src/viem/Transaction.ts +0 -382
- package/src/viem/Transport.ts +0 -191
- package/src/viem/WebAuthnP256.ts +0 -146
- package/src/viem/WebCryptoP256.ts +0 -1
- package/src/viem/e2e.test.ts +0 -1602
- package/src/viem/index.ts +0 -30
- package/src/viem/internal/types.ts +0 -69
- package/src/viem/internal/utils.ts +0 -58
- package/src/wagmi/internal/types.ts +0 -16
package/src/viem/Account.test.ts
DELETED
|
@@ -1,444 +0,0 @@
|
|
|
1
|
-
import { Value, WebCryptoP256 } from 'ox'
|
|
2
|
-
import { SignatureEnvelope } from 'ox/tempo'
|
|
3
|
-
import { describe, expect, test } from 'vitest'
|
|
4
|
-
import * as Account from './Account.js'
|
|
5
|
-
|
|
6
|
-
const privateKey_secp256k1 =
|
|
7
|
-
'0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80'
|
|
8
|
-
const privateKey_p256 =
|
|
9
|
-
'0x5c878151adef73f88b1c360d33e9bf9dd1b6e2e0e07bc555fc33cb8cf6bc9b28'
|
|
10
|
-
|
|
11
|
-
describe('fromSecp256k1', () => {
|
|
12
|
-
test('default', async () => {
|
|
13
|
-
const account = Account.fromSecp256k1(privateKey_secp256k1)
|
|
14
|
-
expect(account).toMatchInlineSnapshot(`
|
|
15
|
-
{
|
|
16
|
-
"address": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266",
|
|
17
|
-
"assignKeyAuthorization": [Function],
|
|
18
|
-
"keyType": "secp256k1",
|
|
19
|
-
"publicKey": "0x8318535b54105d4a7aae60c08fc45f9687181b4fdfc625bd1a753fa7397fed753547f11ca8696646f2f3acb08e31016afac23e630c5d11f59f61fef57b0d2aa5",
|
|
20
|
-
"sign": [Function],
|
|
21
|
-
"signAuthorization": [Function],
|
|
22
|
-
"signKeyAuthorization": [Function],
|
|
23
|
-
"signMessage": [Function],
|
|
24
|
-
"signTransaction": [Function],
|
|
25
|
-
"signTypedData": [Function],
|
|
26
|
-
"source": "root",
|
|
27
|
-
"storage": {
|
|
28
|
-
"getItem": [Function],
|
|
29
|
-
"removeItem": [Function],
|
|
30
|
-
"setItem": [Function],
|
|
31
|
-
},
|
|
32
|
-
"type": "local",
|
|
33
|
-
}
|
|
34
|
-
`)
|
|
35
|
-
|
|
36
|
-
const signature = await account.sign({
|
|
37
|
-
hash: '0xdeadbeef',
|
|
38
|
-
})
|
|
39
|
-
expect(signature).toMatchInlineSnapshot(
|
|
40
|
-
`"0xfa78c5905fb0b9d6066ef531f962a62bc6ef0d5eb59ecb134056d206f75aaed7780926ff2601a935c2c79707d9e1799948c9f19dcdde1e090e903b19a07923d01c"`,
|
|
41
|
-
)
|
|
42
|
-
expect(SignatureEnvelope.deserialize(signature)).toMatchInlineSnapshot(`
|
|
43
|
-
{
|
|
44
|
-
"signature": {
|
|
45
|
-
"r": 113291597329930009559670063131885256927775966057121513567941051428123344285399n,
|
|
46
|
-
"s": 54293712598725100598138577281441749550405991478212695085505730636505228583888n,
|
|
47
|
-
"yParity": 1,
|
|
48
|
-
},
|
|
49
|
-
"type": "secp256k1",
|
|
50
|
-
}
|
|
51
|
-
`)
|
|
52
|
-
})
|
|
53
|
-
|
|
54
|
-
test('behavior: access key', async () => {
|
|
55
|
-
const account = Account.fromSecp256k1(privateKey_secp256k1)
|
|
56
|
-
const access = Account.fromSecp256k1(
|
|
57
|
-
'0x06a952d58c24d287245276dd8b4272d82a921d27d90874a6c27a3bc19ff4bfde',
|
|
58
|
-
{
|
|
59
|
-
access: account,
|
|
60
|
-
},
|
|
61
|
-
)
|
|
62
|
-
|
|
63
|
-
const signature = await access.sign({
|
|
64
|
-
hash: '0xdeadbeef',
|
|
65
|
-
})
|
|
66
|
-
expect(signature).toMatchInlineSnapshot(
|
|
67
|
-
`"0x03f39Fd6e51aad88F6F4ce6aB8827279cffFb9226627c4025daa5c473942fd6282cfb7c07edb48a1764fb3c228fc094a715300e0e56fcf8a7849bb8bcc2938d8a041fdbce56d2b6c70aadbae6a0b70b4a1e98256161b"`,
|
|
68
|
-
)
|
|
69
|
-
expect(SignatureEnvelope.deserialize(signature)).toMatchInlineSnapshot(`
|
|
70
|
-
{
|
|
71
|
-
"inner": {
|
|
72
|
-
"signature": {
|
|
73
|
-
"r": 17986519448152736741806679848301503760738507672285374215138617395147700232421n,
|
|
74
|
-
"s": 50573419219106101097329274608677894804280434221354410855341207650465321473558n,
|
|
75
|
-
"yParity": 0,
|
|
76
|
-
},
|
|
77
|
-
"type": "secp256k1",
|
|
78
|
-
},
|
|
79
|
-
"type": "keychain",
|
|
80
|
-
"userAddress": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266",
|
|
81
|
-
}
|
|
82
|
-
`)
|
|
83
|
-
})
|
|
84
|
-
})
|
|
85
|
-
|
|
86
|
-
describe('fromP256', () => {
|
|
87
|
-
test('default', async () => {
|
|
88
|
-
const account = Account.fromP256(privateKey_p256)
|
|
89
|
-
expect(account).toMatchInlineSnapshot(`
|
|
90
|
-
{
|
|
91
|
-
"address": "0xc3Cf8B814B729A1ad648b49fbBdED3767BCd35fd",
|
|
92
|
-
"assignKeyAuthorization": [Function],
|
|
93
|
-
"keyType": "p256",
|
|
94
|
-
"publicKey": "0x20fe09fa1af47a6b3b4e973040f0588a1c2c96df1ce78b10e50903566ad9b7d87ffe0b281b616196c2ccdb64cd51230d8dc1f1d258ca7e8cb33a63cf8c812240",
|
|
95
|
-
"sign": [Function],
|
|
96
|
-
"signAuthorization": [Function],
|
|
97
|
-
"signKeyAuthorization": [Function],
|
|
98
|
-
"signMessage": [Function],
|
|
99
|
-
"signTransaction": [Function],
|
|
100
|
-
"signTypedData": [Function],
|
|
101
|
-
"source": "root",
|
|
102
|
-
"storage": {
|
|
103
|
-
"getItem": [Function],
|
|
104
|
-
"removeItem": [Function],
|
|
105
|
-
"setItem": [Function],
|
|
106
|
-
},
|
|
107
|
-
"type": "local",
|
|
108
|
-
}
|
|
109
|
-
`)
|
|
110
|
-
|
|
111
|
-
const signature = await account.sign({
|
|
112
|
-
hash: '0xdeadbeef',
|
|
113
|
-
})
|
|
114
|
-
expect(signature).toMatchInlineSnapshot(
|
|
115
|
-
`"0x01daab749a3dea3f76c52ff0cfc86f0d433ecaf4d20f2ea327042bf5c15bccf847098dc3591fc68bf94d8db6d16cf326808dbf0f44d8e8373e8a7fcaf39b38281020fe09fa1af47a6b3b4e973040f0588a1c2c96df1ce78b10e50903566ad9b7d87ffe0b281b616196c2ccdb64cd51230d8dc1f1d258ca7e8cb33a63cf8c81224000"`,
|
|
116
|
-
)
|
|
117
|
-
})
|
|
118
|
-
|
|
119
|
-
test('behavior: access key', async () => {
|
|
120
|
-
const account = Account.fromP256(privateKey_p256)
|
|
121
|
-
const access = Account.fromP256(
|
|
122
|
-
'0x5c878151adef73f88b1c360d33e9bf9dd1b6e2e0e07bc555fc33cb8cf6bc9b28',
|
|
123
|
-
{
|
|
124
|
-
access: account,
|
|
125
|
-
},
|
|
126
|
-
)
|
|
127
|
-
|
|
128
|
-
const signature = await access.sign({
|
|
129
|
-
hash: '0xdeadbeef',
|
|
130
|
-
})
|
|
131
|
-
expect(signature).toMatchInlineSnapshot(
|
|
132
|
-
`"0x03c3Cf8B814B729A1ad648b49fbBdED3767BCd35fd01daab749a3dea3f76c52ff0cfc86f0d433ecaf4d20f2ea327042bf5c15bccf847098dc3591fc68bf94d8db6d16cf326808dbf0f44d8e8373e8a7fcaf39b38281020fe09fa1af47a6b3b4e973040f0588a1c2c96df1ce78b10e50903566ad9b7d87ffe0b281b616196c2ccdb64cd51230d8dc1f1d258ca7e8cb33a63cf8c81224000"`,
|
|
133
|
-
)
|
|
134
|
-
expect(SignatureEnvelope.deserialize(signature)).toMatchInlineSnapshot(`
|
|
135
|
-
{
|
|
136
|
-
"inner": {
|
|
137
|
-
"prehash": false,
|
|
138
|
-
"publicKey": {
|
|
139
|
-
"prefix": 4,
|
|
140
|
-
"x": 14922859167660714031319135249406228569331107293314503672038378501577989797848n,
|
|
141
|
-
"y": 57892587925019714505251703757706314187537979987563648366993255393643804566080n,
|
|
142
|
-
},
|
|
143
|
-
"signature": {
|
|
144
|
-
"r": 98907136600157604623356371387339224256063842362088951992859252568183251204167n,
|
|
145
|
-
"s": 4321289316702385668777418513388640777474210589895706234285069930616319387664n,
|
|
146
|
-
},
|
|
147
|
-
"type": "p256",
|
|
148
|
-
},
|
|
149
|
-
"type": "keychain",
|
|
150
|
-
"userAddress": "0xc3Cf8B814B729A1ad648b49fbBdED3767BCd35fd",
|
|
151
|
-
}
|
|
152
|
-
`)
|
|
153
|
-
})
|
|
154
|
-
})
|
|
155
|
-
|
|
156
|
-
describe('fromHeadlessWebAuthn', () => {
|
|
157
|
-
test('default', async () => {
|
|
158
|
-
const account = Account.fromHeadlessWebAuthn(privateKey_p256, {
|
|
159
|
-
rpId: 'localhost',
|
|
160
|
-
origin: 'http://localhost',
|
|
161
|
-
})
|
|
162
|
-
expect(account).toMatchInlineSnapshot(`
|
|
163
|
-
{
|
|
164
|
-
"address": "0xc3Cf8B814B729A1ad648b49fbBdED3767BCd35fd",
|
|
165
|
-
"assignKeyAuthorization": [Function],
|
|
166
|
-
"keyType": "webAuthn",
|
|
167
|
-
"publicKey": "0x20fe09fa1af47a6b3b4e973040f0588a1c2c96df1ce78b10e50903566ad9b7d87ffe0b281b616196c2ccdb64cd51230d8dc1f1d258ca7e8cb33a63cf8c812240",
|
|
168
|
-
"sign": [Function],
|
|
169
|
-
"signAuthorization": [Function],
|
|
170
|
-
"signKeyAuthorization": [Function],
|
|
171
|
-
"signMessage": [Function],
|
|
172
|
-
"signTransaction": [Function],
|
|
173
|
-
"signTypedData": [Function],
|
|
174
|
-
"source": "root",
|
|
175
|
-
"storage": {
|
|
176
|
-
"getItem": [Function],
|
|
177
|
-
"removeItem": [Function],
|
|
178
|
-
"setItem": [Function],
|
|
179
|
-
},
|
|
180
|
-
"type": "local",
|
|
181
|
-
}
|
|
182
|
-
`)
|
|
183
|
-
|
|
184
|
-
const signature = await account.sign({
|
|
185
|
-
hash: '0xdeadbeef',
|
|
186
|
-
})
|
|
187
|
-
expect(signature).toMatchInlineSnapshot(
|
|
188
|
-
`"0x0249960de5880e8c687434170f6476605b8fe4aeb9a28632c7995cf3ba831d976305000000007b2274797065223a22776562617574686e2e676574222c226368616c6c656e6765223a223371322d3777222c226f726967696e223a22687474703a2f2f6c6f63616c686f7374222c2263726f73734f726967696e223a66616c73657d1b3346991a9ad1498e401dc0448e93d1bde113778d442f5bcafc44925cf3121961e9b1c21b054e54fe6c2eec0cd310c8535b7e7dd1f7dd7bf749e6d78154b48120fe09fa1af47a6b3b4e973040f0588a1c2c96df1ce78b10e50903566ad9b7d87ffe0b281b616196c2ccdb64cd51230d8dc1f1d258ca7e8cb33a63cf8c812240"`,
|
|
189
|
-
)
|
|
190
|
-
})
|
|
191
|
-
|
|
192
|
-
test('behavior: access key', async () => {
|
|
193
|
-
const account = Account.fromHeadlessWebAuthn(privateKey_p256, {
|
|
194
|
-
rpId: 'localhost',
|
|
195
|
-
origin: 'http://localhost',
|
|
196
|
-
})
|
|
197
|
-
const access = Account.fromHeadlessWebAuthn(privateKey_p256, {
|
|
198
|
-
access: account,
|
|
199
|
-
rpId: 'localhost',
|
|
200
|
-
origin: 'http://localhost',
|
|
201
|
-
})
|
|
202
|
-
|
|
203
|
-
const signature = await access.sign({
|
|
204
|
-
hash: '0xdeadbeef',
|
|
205
|
-
})
|
|
206
|
-
expect(signature).toMatchInlineSnapshot(
|
|
207
|
-
`"0x03c3Cf8B814B729A1ad648b49fbBdED3767BCd35fd0249960de5880e8c687434170f6476605b8fe4aeb9a28632c7995cf3ba831d976305000000007b2274797065223a22776562617574686e2e676574222c226368616c6c656e6765223a223371322d3777222c226f726967696e223a22687474703a2f2f6c6f63616c686f7374222c2263726f73734f726967696e223a66616c73657d1b3346991a9ad1498e401dc0448e93d1bde113778d442f5bcafc44925cf3121961e9b1c21b054e54fe6c2eec0cd310c8535b7e7dd1f7dd7bf749e6d78154b48120fe09fa1af47a6b3b4e973040f0588a1c2c96df1ce78b10e50903566ad9b7d87ffe0b281b616196c2ccdb64cd51230d8dc1f1d258ca7e8cb33a63cf8c812240"`,
|
|
208
|
-
)
|
|
209
|
-
expect(SignatureEnvelope.deserialize(signature)).toMatchInlineSnapshot(`
|
|
210
|
-
{
|
|
211
|
-
"inner": {
|
|
212
|
-
"metadata": {
|
|
213
|
-
"authenticatorData": "0x49960de5880e8c687434170f6476605b8fe4aeb9a28632c7995cf3ba831d97630500000000",
|
|
214
|
-
"clientDataJSON": "{"type":"webauthn.get","challenge":"3q2-7w","origin":"http://localhost","crossOrigin":false}",
|
|
215
|
-
},
|
|
216
|
-
"publicKey": {
|
|
217
|
-
"prefix": 4,
|
|
218
|
-
"x": 14922859167660714031319135249406228569331107293314503672038378501577989797848n,
|
|
219
|
-
"y": 57892587925019714505251703757706314187537979987563648366993255393643804566080n,
|
|
220
|
-
},
|
|
221
|
-
"signature": {
|
|
222
|
-
"r": 12303043361969813321008510595799352303777626167191077212436720864556362175001n,
|
|
223
|
-
"s": 44287248520848853208449965274039658906134850867725872574460252467151437608065n,
|
|
224
|
-
},
|
|
225
|
-
"type": "webAuthn",
|
|
226
|
-
},
|
|
227
|
-
"type": "keychain",
|
|
228
|
-
"userAddress": "0xc3Cf8B814B729A1ad648b49fbBdED3767BCd35fd",
|
|
229
|
-
}
|
|
230
|
-
`)
|
|
231
|
-
})
|
|
232
|
-
})
|
|
233
|
-
|
|
234
|
-
describe('fromWebCryptoP256', () => {
|
|
235
|
-
test('default', async () => {
|
|
236
|
-
const keyPair = await WebCryptoP256.createKeyPair()
|
|
237
|
-
const account = Account.fromWebCryptoP256(keyPair)
|
|
238
|
-
expect(account.keyType).toBe('p256')
|
|
239
|
-
})
|
|
240
|
-
})
|
|
241
|
-
|
|
242
|
-
describe('signKeyAuthorization', () => {
|
|
243
|
-
test('default', async () => {
|
|
244
|
-
const account = Account.fromSecp256k1(privateKey_secp256k1)
|
|
245
|
-
const key = Account.fromSecp256k1(privateKey_secp256k1, {
|
|
246
|
-
access: account,
|
|
247
|
-
})
|
|
248
|
-
|
|
249
|
-
const authorization = await account.signKeyAuthorization(key)
|
|
250
|
-
|
|
251
|
-
expect(authorization).toMatchInlineSnapshot(`
|
|
252
|
-
{
|
|
253
|
-
"address": "0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266",
|
|
254
|
-
"expiry": undefined,
|
|
255
|
-
"limits": undefined,
|
|
256
|
-
"signature": {
|
|
257
|
-
"signature": {
|
|
258
|
-
"r": 79205852917725370379355270588870592116219723320468023492479334723587833964208n,
|
|
259
|
-
"s": 4843127791679253574310716587415423223041264865988930666086461408483250881493n,
|
|
260
|
-
"yParity": 1,
|
|
261
|
-
},
|
|
262
|
-
"type": "secp256k1",
|
|
263
|
-
},
|
|
264
|
-
"type": "secp256k1",
|
|
265
|
-
}
|
|
266
|
-
`)
|
|
267
|
-
})
|
|
268
|
-
|
|
269
|
-
test('secp256k1', async () => {
|
|
270
|
-
const account = Account.fromSecp256k1(privateKey_secp256k1)
|
|
271
|
-
const key = Account.fromSecp256k1(privateKey_secp256k1, {
|
|
272
|
-
access: account,
|
|
273
|
-
})
|
|
274
|
-
|
|
275
|
-
const authorization = await account.signKeyAuthorization(key, {
|
|
276
|
-
expiry: 1234567890,
|
|
277
|
-
limits: [
|
|
278
|
-
{
|
|
279
|
-
token: '0x20c0000000000000000000000000000000000001',
|
|
280
|
-
limit: Value.from('10', 6),
|
|
281
|
-
},
|
|
282
|
-
],
|
|
283
|
-
})
|
|
284
|
-
expect(authorization).toMatchInlineSnapshot(`
|
|
285
|
-
{
|
|
286
|
-
"address": "0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266",
|
|
287
|
-
"expiry": 1234567890,
|
|
288
|
-
"limits": [
|
|
289
|
-
{
|
|
290
|
-
"limit": 10000000n,
|
|
291
|
-
"token": "0x20c0000000000000000000000000000000000001",
|
|
292
|
-
},
|
|
293
|
-
],
|
|
294
|
-
"signature": {
|
|
295
|
-
"signature": {
|
|
296
|
-
"r": 48603032183460068649726257603541287031240449157747147951793434940348798421977n,
|
|
297
|
-
"s": 52252948283033674801195452183159160801795536276956563866652050470169279213377n,
|
|
298
|
-
"yParity": 1,
|
|
299
|
-
},
|
|
300
|
-
"type": "secp256k1",
|
|
301
|
-
},
|
|
302
|
-
"type": "secp256k1",
|
|
303
|
-
}
|
|
304
|
-
`)
|
|
305
|
-
})
|
|
306
|
-
|
|
307
|
-
test('p256', async () => {
|
|
308
|
-
const account = Account.fromP256(privateKey_p256)
|
|
309
|
-
const key = Account.fromSecp256k1(privateKey_p256, {
|
|
310
|
-
access: account,
|
|
311
|
-
})
|
|
312
|
-
|
|
313
|
-
const authorization = await account.signKeyAuthorization(key, {
|
|
314
|
-
expiry: 1234567890,
|
|
315
|
-
limits: [
|
|
316
|
-
{
|
|
317
|
-
token: '0x20c0000000000000000000000000000000000001',
|
|
318
|
-
limit: Value.from('10', 6),
|
|
319
|
-
},
|
|
320
|
-
],
|
|
321
|
-
})
|
|
322
|
-
expect(authorization).toMatchInlineSnapshot(`
|
|
323
|
-
{
|
|
324
|
-
"address": "0x7b9f73245dee5855ef858f5c00eea6205f9bb4d2",
|
|
325
|
-
"expiry": 1234567890,
|
|
326
|
-
"limits": [
|
|
327
|
-
{
|
|
328
|
-
"limit": 10000000n,
|
|
329
|
-
"token": "0x20c0000000000000000000000000000000000001",
|
|
330
|
-
},
|
|
331
|
-
],
|
|
332
|
-
"signature": {
|
|
333
|
-
"prehash": false,
|
|
334
|
-
"publicKey": {
|
|
335
|
-
"prefix": 4,
|
|
336
|
-
"x": 14922859167660714031319135249406228569331107293314503672038378501577989797848n,
|
|
337
|
-
"y": 57892587925019714505251703757706314187537979987563648366993255393643804566080n,
|
|
338
|
-
},
|
|
339
|
-
"signature": {
|
|
340
|
-
"r": 61783347383434217927888325272237644430195567463134160594444735116547420206984n,
|
|
341
|
-
"s": 11737632122119624918549121055165681708107124199303685870565323985056705147576n,
|
|
342
|
-
},
|
|
343
|
-
"type": "p256",
|
|
344
|
-
},
|
|
345
|
-
"type": "secp256k1",
|
|
346
|
-
}
|
|
347
|
-
`)
|
|
348
|
-
})
|
|
349
|
-
|
|
350
|
-
test('webAuthn', async () => {
|
|
351
|
-
const account = Account.fromHeadlessWebAuthn(privateKey_p256, {
|
|
352
|
-
rpId: 'localhost',
|
|
353
|
-
origin: 'http://localhost',
|
|
354
|
-
})
|
|
355
|
-
const key = Account.fromSecp256k1(privateKey_secp256k1, {
|
|
356
|
-
access: account,
|
|
357
|
-
})
|
|
358
|
-
|
|
359
|
-
const authorization = await account.signKeyAuthorization(key, {
|
|
360
|
-
expiry: 1234567890,
|
|
361
|
-
limits: [
|
|
362
|
-
{
|
|
363
|
-
token: '0x20c0000000000000000000000000000000000001',
|
|
364
|
-
limit: Value.from('10', 6),
|
|
365
|
-
},
|
|
366
|
-
],
|
|
367
|
-
})
|
|
368
|
-
expect(authorization).toMatchInlineSnapshot(`
|
|
369
|
-
{
|
|
370
|
-
"address": "0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266",
|
|
371
|
-
"expiry": 1234567890,
|
|
372
|
-
"limits": [
|
|
373
|
-
{
|
|
374
|
-
"limit": 10000000n,
|
|
375
|
-
"token": "0x20c0000000000000000000000000000000000001",
|
|
376
|
-
},
|
|
377
|
-
],
|
|
378
|
-
"signature": {
|
|
379
|
-
"metadata": {
|
|
380
|
-
"authenticatorData": "0x49960de5880e8c687434170f6476605b8fe4aeb9a28632c7995cf3ba831d97630500000000",
|
|
381
|
-
"clientDataJSON": "{"type":"webauthn.get","challenge":"lGAMxkLdccXnNTMWbfQ1rYi8HBqAdMPo1CDv0cJ2IsE","origin":"http://localhost","crossOrigin":false}",
|
|
382
|
-
},
|
|
383
|
-
"publicKey": {
|
|
384
|
-
"prefix": 4,
|
|
385
|
-
"x": 14922859167660714031319135249406228569331107293314503672038378501577989797848n,
|
|
386
|
-
"y": 57892587925019714505251703757706314187537979987563648366993255393643804566080n,
|
|
387
|
-
},
|
|
388
|
-
"signature": {
|
|
389
|
-
"r": 78216200649325922174765550266136727201161525335688064274452437990389629688142n,
|
|
390
|
-
"s": 45615041673857220498429503388722739621903077428603741554126666038202271956449n,
|
|
391
|
-
},
|
|
392
|
-
"type": "webAuthn",
|
|
393
|
-
},
|
|
394
|
-
"type": "secp256k1",
|
|
395
|
-
}
|
|
396
|
-
`)
|
|
397
|
-
})
|
|
398
|
-
|
|
399
|
-
test('multiple limits', async () => {
|
|
400
|
-
const account = Account.fromSecp256k1(privateKey_secp256k1)
|
|
401
|
-
const key = Account.fromSecp256k1(privateKey_secp256k1, {
|
|
402
|
-
access: account,
|
|
403
|
-
})
|
|
404
|
-
|
|
405
|
-
const authorization = await account.signKeyAuthorization(key, {
|
|
406
|
-
expiry: 1234567890,
|
|
407
|
-
limits: [
|
|
408
|
-
{
|
|
409
|
-
token: '0x20c0000000000000000000000000000000000001',
|
|
410
|
-
limit: Value.from('10', 6),
|
|
411
|
-
},
|
|
412
|
-
{
|
|
413
|
-
token: '0x20c0000000000000000000000000000000000002',
|
|
414
|
-
limit: Value.from('20', 6),
|
|
415
|
-
},
|
|
416
|
-
],
|
|
417
|
-
})
|
|
418
|
-
expect(authorization).toMatchInlineSnapshot(`
|
|
419
|
-
{
|
|
420
|
-
"address": "0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266",
|
|
421
|
-
"expiry": 1234567890,
|
|
422
|
-
"limits": [
|
|
423
|
-
{
|
|
424
|
-
"limit": 10000000n,
|
|
425
|
-
"token": "0x20c0000000000000000000000000000000000001",
|
|
426
|
-
},
|
|
427
|
-
{
|
|
428
|
-
"limit": 20000000n,
|
|
429
|
-
"token": "0x20c0000000000000000000000000000000000002",
|
|
430
|
-
},
|
|
431
|
-
],
|
|
432
|
-
"signature": {
|
|
433
|
-
"signature": {
|
|
434
|
-
"r": 103446563773805832555738463837136311499830712555215862064308154410957015968940n,
|
|
435
|
-
"s": 19247215858016211284757060583528935834485291841858715669623661689922072500812n,
|
|
436
|
-
"yParity": 0,
|
|
437
|
-
},
|
|
438
|
-
"type": "secp256k1",
|
|
439
|
-
},
|
|
440
|
-
"type": "secp256k1",
|
|
441
|
-
}
|
|
442
|
-
`)
|
|
443
|
-
})
|
|
444
|
-
})
|