ox 1.8.14 → 1.8.16
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 +72 -0
- package/dist/core/AbiError.d.ts +52 -6
- package/dist/core/AbiError.d.ts.map +1 -1
- package/dist/core/AbiError.js +60 -4
- package/dist/core/AbiError.js.map +1 -1
- package/dist/core/AbiEvent.d.ts +4 -2
- package/dist/core/AbiEvent.d.ts.map +1 -1
- package/dist/core/AbiEvent.js +62 -36
- package/dist/core/AbiEvent.js.map +1 -1
- package/dist/core/AbiFunction.d.ts +48 -2
- package/dist/core/AbiFunction.d.ts.map +1 -1
- package/dist/core/AbiFunction.js +59 -3
- package/dist/core/AbiFunction.js.map +1 -1
- package/dist/core/Address.d.ts +17 -2
- package/dist/core/Address.d.ts.map +1 -1
- package/dist/core/Address.js +17 -1
- package/dist/core/Address.js.map +1 -1
- package/dist/core/Authorization.d.ts +24 -2
- package/dist/core/Authorization.d.ts.map +1 -1
- package/dist/core/Authorization.js +29 -2
- package/dist/core/Authorization.js.map +1 -1
- package/dist/core/Keystore.d.ts +31 -2
- package/dist/core/Keystore.d.ts.map +1 -1
- package/dist/core/Keystore.js +28 -2
- package/dist/core/Keystore.js.map +1 -1
- package/dist/core/Secp256k1.d.ts.map +1 -1
- package/dist/core/Secp256k1.js +4 -1
- package/dist/core/Secp256k1.js.map +1 -1
- package/dist/core/Signature.d.ts +1 -1
- package/dist/core/Signature.d.ts.map +1 -1
- package/dist/core/Signature.js +4 -2
- package/dist/core/Signature.js.map +1 -1
- package/dist/core/Siwe.d.ts +4 -0
- package/dist/core/Siwe.d.ts.map +1 -1
- package/dist/core/Siwe.js +29 -3
- package/dist/core/Siwe.js.map +1 -1
- package/dist/core/TxEnvelopeEip1559.d.ts.map +1 -1
- package/dist/core/TxEnvelopeEip1559.js +2 -1
- package/dist/core/TxEnvelopeEip1559.js.map +1 -1
- package/dist/core/TxEnvelopeEip2930.d.ts.map +1 -1
- package/dist/core/TxEnvelopeEip2930.js +2 -1
- package/dist/core/TxEnvelopeEip2930.js.map +1 -1
- package/dist/core/TxEnvelopeEip7702.d.ts +1 -1
- package/dist/core/TxEnvelopeEip7702.d.ts.map +1 -1
- package/dist/core/TxEnvelopeEip7702.js +6 -1
- package/dist/core/TxEnvelopeEip7702.js.map +1 -1
- package/dist/core/TxEnvelopeLegacy.d.ts.map +1 -1
- package/dist/core/TxEnvelopeLegacy.js +49 -7
- package/dist/core/TxEnvelopeLegacy.js.map +1 -1
- package/dist/core/TypedData.d.ts +3 -1
- package/dist/core/TypedData.d.ts.map +1 -1
- package/dist/core/TypedData.js +9 -9
- package/dist/core/TypedData.js.map +1 -1
- package/dist/core/Value.d.ts.map +1 -1
- package/dist/core/Value.js +14 -3
- package/dist/core/Value.js.map +1 -1
- package/dist/core/internal/abiParameters.d.ts +1 -1
- package/dist/core/internal/abiParameters.d.ts.map +1 -1
- package/dist/core/internal/abiParameters.js +7 -2
- package/dist/core/internal/abiParameters.js.map +1 -1
- package/dist/core/internal/cursor.d.ts +13 -0
- package/dist/core/internal/cursor.d.ts.map +1 -1
- package/dist/core/internal/cursor.js +27 -0
- package/dist/core/internal/cursor.js.map +1 -1
- package/dist/erc4337/UserOperation.d.ts.map +1 -1
- package/dist/erc4337/UserOperation.js +1 -3
- package/dist/erc4337/UserOperation.js.map +1 -1
- package/dist/erc7821/Execute.d.ts +45 -0
- package/dist/erc7821/Execute.d.ts.map +1 -1
- package/dist/erc7821/Execute.js +70 -2
- package/dist/erc7821/Execute.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/tempo/KeyAuthorization.d.ts +9 -3
- package/dist/tempo/KeyAuthorization.d.ts.map +1 -1
- package/dist/tempo/KeyAuthorization.js +16 -0
- package/dist/tempo/KeyAuthorization.js.map +1 -1
- package/dist/tempo/SignatureEnvelope.d.ts +1 -1
- package/dist/tempo/SignatureEnvelope.d.ts.map +1 -1
- package/dist/tempo/SignatureEnvelope.js +46 -13
- package/dist/tempo/SignatureEnvelope.js.map +1 -1
- package/dist/tempo/SignaturePreAuthorized.d.ts +192 -0
- package/dist/tempo/SignaturePreAuthorized.d.ts.map +1 -0
- package/dist/tempo/SignaturePreAuthorized.js +299 -0
- package/dist/tempo/SignaturePreAuthorized.js.map +1 -0
- package/dist/tempo/TransactionRequest.d.ts +1 -1
- package/dist/tempo/TransactionRequest.d.ts.map +1 -1
- package/dist/tempo/TransactionRequest.js +5 -2
- package/dist/tempo/TransactionRequest.js.map +1 -1
- package/dist/tempo/TxEnvelopeTempo.d.ts +30 -1
- package/dist/tempo/TxEnvelopeTempo.d.ts.map +1 -1
- package/dist/tempo/TxEnvelopeTempo.js +51 -2
- package/dist/tempo/TxEnvelopeTempo.js.map +1 -1
- package/dist/tempo/index.d.ts +26 -0
- package/dist/tempo/index.d.ts.map +1 -1
- package/dist/tempo/index.js +26 -0
- package/dist/tempo/index.js.map +1 -1
- package/dist/webauthn/Registration.d.ts +2 -0
- package/dist/webauthn/Registration.d.ts.map +1 -1
- package/dist/webauthn/Registration.js +2 -6
- package/dist/webauthn/Registration.js.map +1 -1
- package/dist/zod/tempo/KeyAuthorization.d.ts.map +1 -1
- package/dist/zod/tempo/KeyAuthorization.js +4 -2
- package/dist/zod/tempo/KeyAuthorization.js.map +1 -1
- package/dist/zod/tempo/SignatureEnvelope.d.ts.map +1 -1
- package/dist/zod/tempo/SignatureEnvelope.js +24 -14
- package/dist/zod/tempo/SignatureEnvelope.js.map +1 -1
- package/package.json +6 -1
- package/src/core/AbiError.ts +82 -8
- package/src/core/AbiEvent.ts +90 -45
- package/src/core/AbiFunction.ts +76 -4
- package/src/core/Address.ts +18 -1
- package/src/core/Authorization.ts +34 -4
- package/src/core/Keystore.ts +40 -3
- package/src/core/Secp256k1.ts +4 -1
- package/src/core/Signature.ts +7 -3
- package/src/core/Siwe.ts +29 -3
- package/src/core/TxEnvelopeEip1559.ts +4 -1
- package/src/core/TxEnvelopeEip2930.ts +4 -1
- package/src/core/TxEnvelopeEip7702.ts +9 -2
- package/src/core/TxEnvelopeLegacy.ts +58 -7
- package/src/core/TypedData.ts +10 -9
- package/src/core/Value.ts +14 -3
- package/src/core/_test/AbiError.test.ts +105 -2
- package/src/core/_test/AbiEvent.fuzz.ts +1 -1
- package/src/core/_test/AbiEvent.test-d.ts +46 -0
- package/src/core/_test/AbiEvent.test.ts +563 -11
- package/src/core/_test/AbiFunction.test.ts +74 -2
- package/src/core/_test/AbiParameters.adversarial.fuzz.ts +1 -0
- package/src/core/_test/AbiParameters.decode.test.ts +110 -0
- package/src/core/_test/AbiParameters.encode.test.ts +26 -1
- package/src/core/_test/Address.test.ts +41 -0
- package/src/core/_test/Authorization.test.ts +130 -0
- package/src/core/_test/Keystore.test.ts +65 -1
- package/src/core/_test/Secp256k1.test.ts +36 -0
- package/src/core/_test/Signature.test.ts +102 -0
- package/src/core/_test/Siwe.test.ts +123 -0
- package/src/core/_test/TransactionEnvelopeEip1559.test.ts +28 -0
- package/src/core/_test/TransactionEnvelopeEip2930.test.ts +28 -0
- package/src/core/_test/TransactionEnvelopeEip7702.test.ts +133 -0
- package/src/core/_test/TransactionEnvelopeLegacy.test.ts +322 -1
- package/src/core/_test/TypedData.test.ts +178 -0
- package/src/core/_test/Value.test.ts +21 -0
- package/src/core/_test/internal/cursor.test.ts +35 -0
- package/src/core/internal/abiParameters.ts +7 -2
- package/src/core/internal/cursor.ts +36 -0
- package/src/erc4337/UserOperation.ts +3 -4
- package/src/erc4337/_test/UserOperation.test.ts +59 -1
- package/src/erc7821/Execute.ts +83 -2
- package/src/erc7821/_test/Execute.test.ts +217 -1
- package/src/index.ts +1 -1
- package/src/tempo/KeyAuthorization.test.ts +91 -0
- package/src/tempo/KeyAuthorization.ts +32 -3
- package/src/tempo/SignatureEnvelope.test.ts +211 -27
- package/src/tempo/SignatureEnvelope.ts +55 -11
- package/src/tempo/SignaturePreAuthorized.test-d.ts +29 -0
- package/src/tempo/SignaturePreAuthorized.test.ts +410 -0
- package/src/tempo/SignaturePreAuthorized.ts +370 -0
- package/src/tempo/TransactionRequest.test.ts +30 -0
- package/src/tempo/TransactionRequest.ts +7 -2
- package/src/tempo/TxEnvelopeTempo.test.ts +310 -0
- package/src/tempo/TxEnvelopeTempo.ts +64 -1
- package/src/tempo/configurableAccounts.e2e.test.ts +1 -1
- package/src/tempo/index.ts +26 -0
- package/src/version.ts +1 -1
- package/src/webauthn/Registration.ts +4 -6
- package/src/webauthn/_test/Registration.browser.test.ts +14 -0
- package/src/webauthn/_test/Registration.test.ts +60 -0
- package/src/zod/tempo/KeyAuthorization.ts +12 -5
- package/src/zod/tempo/SignatureEnvelope.ts +31 -16
- package/src/zod/tempo/_test/KeyAuthorization.test.ts +36 -0
- package/src/zod/tempo/_test/SignatureEnvelope.test.ts +101 -3
|
@@ -40,13 +40,24 @@ const Signature = z.object({
|
|
|
40
40
|
})
|
|
41
41
|
|
|
42
42
|
/** RPC secp256k1 signature envelope schema. */
|
|
43
|
-
export const Secp256k1Rpc = z
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
43
|
+
export const Secp256k1Rpc = z
|
|
44
|
+
.object({
|
|
45
|
+
r: z_Hex.Hex,
|
|
46
|
+
s: z_Hex.Hex,
|
|
47
|
+
type: z.literal('secp256k1'),
|
|
48
|
+
v: z.optional(z_Hex.Hex),
|
|
49
|
+
yParity: z.optional(z_Hex.Hex),
|
|
50
|
+
})
|
|
51
|
+
.check(
|
|
52
|
+
z.refine((value) => {
|
|
53
|
+
try {
|
|
54
|
+
toYParity(value.v, value.yParity)
|
|
55
|
+
return true
|
|
56
|
+
} catch {
|
|
57
|
+
return false
|
|
58
|
+
}
|
|
59
|
+
}, 'expected yParity or supported v'),
|
|
60
|
+
)
|
|
50
61
|
|
|
51
62
|
/** RPC P256 signature envelope schema. */
|
|
52
63
|
export const P256Rpc = z.object({
|
|
@@ -65,7 +76,13 @@ export const WebAuthnRpc = z.object({
|
|
|
65
76
|
r: z_Hex.Hex,
|
|
66
77
|
s: z_Hex.Hex,
|
|
67
78
|
type: z.literal('webAuthn'),
|
|
68
|
-
|
|
79
|
+
// 2048-byte WebAuthn signature limit minus the 128-byte signature and public key.
|
|
80
|
+
webauthnData: z_Hex.Hex.check(
|
|
81
|
+
z.refine(
|
|
82
|
+
(value) => core_Hex.size(value) <= 1920,
|
|
83
|
+
'expected at most 1920 bytes',
|
|
84
|
+
),
|
|
85
|
+
),
|
|
69
86
|
})
|
|
70
87
|
|
|
71
88
|
/** RPC primitive signature envelope schema. */
|
|
@@ -324,14 +341,12 @@ function toYParity(
|
|
|
324
341
|
v: core_Hex.Hex | undefined,
|
|
325
342
|
yParity: core_Hex.Hex | undefined,
|
|
326
343
|
) {
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
if (
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
}
|
|
334
|
-
return yParity_ as 0 | 1
|
|
344
|
+
if (yParity) return Number(yParity) as 0 | 1
|
|
345
|
+
const v_ = v && v !== '0x' ? BigInt(v) : undefined
|
|
346
|
+
if (v_ === 0n || v_ === 27n) return 0
|
|
347
|
+
if (v_ === 1n || v_ === 28n) return 1
|
|
348
|
+
if (typeof v_ === 'bigint' && v_ >= 35n) return v_ % 2n === 0n ? 1 : 0
|
|
349
|
+
throw new Error('Unable to derive yParity: expected yParity or supported v')
|
|
335
350
|
}
|
|
336
351
|
|
|
337
352
|
/** Parses concatenated WebAuthn metadata into its component parts. */
|
|
@@ -171,6 +171,42 @@ describe('KeyAuthorization', () => {
|
|
|
171
171
|
).toBe(false)
|
|
172
172
|
})
|
|
173
173
|
|
|
174
|
+
test('rejects recipients without a selector', () => {
|
|
175
|
+
const address = '0x20c0000000000000000000000000000000000001'
|
|
176
|
+
const recipients = ['0x1111111111111111111111111111111111111111']
|
|
177
|
+
expect(
|
|
178
|
+
z.safeParse(z_KeyAuthorization.Scope, { address, recipients }).error
|
|
179
|
+
?.issues,
|
|
180
|
+
).toMatchInlineSnapshot(`
|
|
181
|
+
[
|
|
182
|
+
{
|
|
183
|
+
"code": "custom",
|
|
184
|
+
"message": "recipients require a selector",
|
|
185
|
+
"path": [],
|
|
186
|
+
},
|
|
187
|
+
]
|
|
188
|
+
`)
|
|
189
|
+
expect(
|
|
190
|
+
z.safeEncode(z_KeyAuthorization.KeyAuthorization, {
|
|
191
|
+
...core_KeyAuthorization.fromRpc(rpc),
|
|
192
|
+
scopes: [{ address, recipients }],
|
|
193
|
+
} as never).success,
|
|
194
|
+
).toBe(false)
|
|
195
|
+
expect(
|
|
196
|
+
[
|
|
197
|
+
{ address },
|
|
198
|
+
{ address, recipients: [] },
|
|
199
|
+
{ address, recipients, selector: '0xa9059cbb' },
|
|
200
|
+
].map((scope) => z.safeParse(z_KeyAuthorization.Scope, scope).success),
|
|
201
|
+
).toMatchInlineSnapshot(`
|
|
202
|
+
[
|
|
203
|
+
true,
|
|
204
|
+
true,
|
|
205
|
+
true,
|
|
206
|
+
]
|
|
207
|
+
`)
|
|
208
|
+
})
|
|
209
|
+
|
|
174
210
|
test('rejects legacy signatures without a config', () => {
|
|
175
211
|
const legacyRpc = {
|
|
176
212
|
account: '0x1111111111111111111111111111111111111111',
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { describe, expect, test } from 'vp/test'
|
|
2
|
+
import * as core_Hex from '../../../core/Hex.js'
|
|
2
3
|
import * as core_SignatureEnvelope from '../../../tempo/SignatureEnvelope.js'
|
|
3
4
|
import * as z_SignatureEnvelope from '../SignatureEnvelope.js'
|
|
4
5
|
import * as z from 'zod/mini'
|
|
@@ -49,6 +50,42 @@ describe('SignatureEnvelope', () => {
|
|
|
49
50
|
)
|
|
50
51
|
})
|
|
51
52
|
|
|
53
|
+
test('rejects WebAuthn data above the maximum size', () => {
|
|
54
|
+
const webAuthn = {
|
|
55
|
+
pubKeyX: p256.pubKeyX,
|
|
56
|
+
pubKeyY: p256.pubKeyY,
|
|
57
|
+
r: p256.r,
|
|
58
|
+
s: p256.s,
|
|
59
|
+
type: 'webAuthn',
|
|
60
|
+
} as const
|
|
61
|
+
// 37 (authenticatorData) + 16 + length (clientDataJSON) bytes
|
|
62
|
+
const webauthnData = (length: number) =>
|
|
63
|
+
core_Hex.concat(
|
|
64
|
+
`0x${'00'.repeat(37)}`,
|
|
65
|
+
core_Hex.fromString(JSON.stringify({ challenge: 'a'.repeat(length) })),
|
|
66
|
+
)
|
|
67
|
+
const max = { ...webAuthn, webauthnData: webauthnData(1867) }
|
|
68
|
+
expect(z.decode(z_SignatureEnvelope.SignatureEnvelope, max)).toEqual(
|
|
69
|
+
core_SignatureEnvelope.fromRpc(max),
|
|
70
|
+
)
|
|
71
|
+
expect(
|
|
72
|
+
z.safeDecode(z_SignatureEnvelope.SignatureEnvelope, {
|
|
73
|
+
...webAuthn,
|
|
74
|
+
webauthnData: webauthnData(1868),
|
|
75
|
+
}).error?.issues,
|
|
76
|
+
).toMatchInlineSnapshot(`
|
|
77
|
+
[
|
|
78
|
+
{
|
|
79
|
+
"code": "custom",
|
|
80
|
+
"message": "expected at most 1920 bytes",
|
|
81
|
+
"path": [
|
|
82
|
+
"webauthnData",
|
|
83
|
+
],
|
|
84
|
+
},
|
|
85
|
+
]
|
|
86
|
+
`)
|
|
87
|
+
})
|
|
88
|
+
|
|
52
89
|
test('decodes a recursive keychain envelope', () => {
|
|
53
90
|
const keychain = {
|
|
54
91
|
signature: secp256k1,
|
|
@@ -140,10 +177,71 @@ describe('SignatureEnvelope', () => {
|
|
|
140
177
|
),
|
|
141
178
|
).toEqual(rpc)
|
|
142
179
|
})
|
|
180
|
+
|
|
181
|
+
test('derives yParity from v when yParity is omitted', () => {
|
|
182
|
+
const { yParity: _, ...rest } = secp256k1
|
|
183
|
+
expect(
|
|
184
|
+
(
|
|
185
|
+
[
|
|
186
|
+
'0x0',
|
|
187
|
+
'0x1',
|
|
188
|
+
'0x1b',
|
|
189
|
+
'0x1c',
|
|
190
|
+
'0x25',
|
|
191
|
+
'0x26',
|
|
192
|
+
'0x1fffffffffffff',
|
|
193
|
+
'0x20000000000001',
|
|
194
|
+
'0x20000000000002',
|
|
195
|
+
'0xffffffffffffffff',
|
|
196
|
+
] as const
|
|
197
|
+
).map(
|
|
198
|
+
(v) =>
|
|
199
|
+
(
|
|
200
|
+
z.decode(z_SignatureEnvelope.SignatureEnvelope, {
|
|
201
|
+
...rest,
|
|
202
|
+
v,
|
|
203
|
+
}) as core_SignatureEnvelope.Secp256k1
|
|
204
|
+
).signature.yParity,
|
|
205
|
+
),
|
|
206
|
+
).toMatchInlineSnapshot(`
|
|
207
|
+
[
|
|
208
|
+
0,
|
|
209
|
+
1,
|
|
210
|
+
0,
|
|
211
|
+
1,
|
|
212
|
+
0,
|
|
213
|
+
1,
|
|
214
|
+
0,
|
|
215
|
+
0,
|
|
216
|
+
1,
|
|
217
|
+
0,
|
|
218
|
+
]
|
|
219
|
+
`)
|
|
220
|
+
})
|
|
221
|
+
|
|
222
|
+
test('prefers yParity over v', () => {
|
|
223
|
+
expect(
|
|
224
|
+
z.decode(z_SignatureEnvelope.SignatureEnvelope, {
|
|
225
|
+
...secp256k1,
|
|
226
|
+
v: '0x1c',
|
|
227
|
+
}),
|
|
228
|
+
).toEqual(core_SignatureEnvelope.fromRpc(secp256k1))
|
|
229
|
+
})
|
|
230
|
+
|
|
231
|
+
test('rejects secp256k1 envelopes without yParity or a supported v', () => {
|
|
232
|
+
const { yParity: _, ...rest } = secp256k1
|
|
233
|
+
for (const v of ['0x2', '0x1a', '0x1d', '0x22', '0x', undefined])
|
|
234
|
+
expect(
|
|
235
|
+
z.safeDecode(z_SignatureEnvelope.SignatureEnvelope, {
|
|
236
|
+
...rest,
|
|
237
|
+
...(v ? { v } : {}),
|
|
238
|
+
} as never).success,
|
|
239
|
+
).toMatchInlineSnapshot(`false`)
|
|
240
|
+
})
|
|
143
241
|
})
|
|
144
242
|
|
|
145
243
|
describe('Keychain', () => {
|
|
146
|
-
test('rejects
|
|
244
|
+
test('rejects keychain wrappers around keychain-wrapped configurable delegates', () => {
|
|
147
245
|
const inner = {
|
|
148
246
|
inner: envelope,
|
|
149
247
|
type: 'keychain',
|
|
@@ -179,12 +277,12 @@ describe('Keychain', () => {
|
|
|
179
277
|
...value,
|
|
180
278
|
version: 'v2',
|
|
181
279
|
}).success,
|
|
182
|
-
).toMatchInlineSnapshot(`
|
|
280
|
+
).toMatchInlineSnapshot(`false`)
|
|
183
281
|
expect(
|
|
184
282
|
z.safeDecode(z_SignatureEnvelope.SignatureEnvelope, {
|
|
185
283
|
...rpc,
|
|
186
284
|
version: 'v2',
|
|
187
285
|
}).success,
|
|
188
|
-
).toMatchInlineSnapshot(`
|
|
286
|
+
).toMatchInlineSnapshot(`false`)
|
|
189
287
|
})
|
|
190
288
|
})
|