ox 0.14.65 → 0.14.66
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 +62 -0
- package/_cjs/core/AbiError.js +25 -4
- package/_cjs/core/AbiError.js.map +1 -1
- package/_cjs/core/AbiEvent.js +18 -3
- package/_cjs/core/AbiEvent.js.map +1 -1
- package/_cjs/core/AbiFunction.js +27 -3
- package/_cjs/core/AbiFunction.js.map +1 -1
- package/_cjs/core/Address.js +1 -0
- package/_cjs/core/Address.js.map +1 -1
- package/_cjs/core/Authorization.js +29 -2
- package/_cjs/core/Authorization.js.map +1 -1
- package/_cjs/core/Keystore.js +18 -0
- package/_cjs/core/Keystore.js.map +1 -1
- package/_cjs/core/Secp256k1.js +5 -1
- package/_cjs/core/Secp256k1.js.map +1 -1
- package/_cjs/core/Signature.js +4 -2
- package/_cjs/core/Signature.js.map +1 -1
- package/_cjs/core/Siwe.js +22 -3
- package/_cjs/core/Siwe.js.map +1 -1
- package/_cjs/core/TxEnvelopeEip1559.js +2 -1
- package/_cjs/core/TxEnvelopeEip1559.js.map +1 -1
- package/_cjs/core/TxEnvelopeEip2930.js +2 -1
- package/_cjs/core/TxEnvelopeEip2930.js.map +1 -1
- package/_cjs/core/TxEnvelopeEip7702.js +5 -1
- package/_cjs/core/TxEnvelopeEip7702.js.map +1 -1
- package/_cjs/core/TxEnvelopeLegacy.js +41 -8
- package/_cjs/core/TxEnvelopeLegacy.js.map +1 -1
- package/_cjs/core/TypedData.js +7 -9
- package/_cjs/core/TypedData.js.map +1 -1
- package/_cjs/core/Value.js +8 -3
- package/_cjs/core/Value.js.map +1 -1
- package/_cjs/core/internal/abiParameters.js +6 -2
- package/_cjs/core/internal/abiParameters.js.map +1 -1
- package/_cjs/core/internal/cursor.js +30 -1
- package/_cjs/core/internal/cursor.js.map +1 -1
- package/_cjs/erc4337/UserOperation.js +1 -1
- package/_cjs/erc4337/UserOperation.js.map +1 -1
- package/_cjs/erc7821/Execute.js +41 -3
- package/_cjs/erc7821/Execute.js.map +1 -1
- package/_cjs/tempo/KeyAuthorization.js +22 -1
- package/_cjs/tempo/KeyAuthorization.js.map +1 -1
- package/_cjs/tempo/SignatureEnvelope.js +37 -12
- package/_cjs/tempo/SignatureEnvelope.js.map +1 -1
- package/_cjs/tempo/TxEnvelopeTempo.js +34 -3
- package/_cjs/tempo/TxEnvelopeTempo.js.map +1 -1
- package/_cjs/version.js +1 -1
- package/_cjs/webauthn/Registration.js +2 -6
- package/_cjs/webauthn/Registration.js.map +1 -1
- package/_esm/core/AbiError.js +64 -3
- package/_esm/core/AbiError.js.map +1 -1
- package/_esm/core/AbiEvent.js +24 -3
- package/_esm/core/AbiEvent.js.map +1 -1
- package/_esm/core/AbiFunction.js +64 -3
- package/_esm/core/AbiFunction.js.map +1 -1
- package/_esm/core/Address.js +17 -1
- package/_esm/core/Address.js.map +1 -1
- package/_esm/core/Authorization.js +47 -2
- package/_esm/core/Authorization.js.map +1 -1
- package/_esm/core/Keystore.js +33 -2
- package/_esm/core/Keystore.js.map +1 -1
- package/_esm/core/Secp256k1.js +5 -1
- package/_esm/core/Secp256k1.js.map +1 -1
- package/_esm/core/Signature.js +4 -2
- package/_esm/core/Signature.js.map +1 -1
- package/_esm/core/Siwe.js +29 -3
- package/_esm/core/Siwe.js.map +1 -1
- package/_esm/core/TxEnvelopeEip1559.js +2 -1
- package/_esm/core/TxEnvelopeEip1559.js.map +1 -1
- package/_esm/core/TxEnvelopeEip2930.js +2 -1
- package/_esm/core/TxEnvelopeEip2930.js.map +1 -1
- package/_esm/core/TxEnvelopeEip7702.js +6 -1
- package/_esm/core/TxEnvelopeEip7702.js.map +1 -1
- package/_esm/core/TxEnvelopeLegacy.js +49 -9
- package/_esm/core/TxEnvelopeLegacy.js.map +1 -1
- package/_esm/core/TypedData.js +9 -9
- package/_esm/core/TypedData.js.map +1 -1
- package/_esm/core/Value.js +14 -3
- package/_esm/core/Value.js.map +1 -1
- package/_esm/core/internal/abiParameters.js +9 -2
- package/_esm/core/internal/abiParameters.js.map +1 -1
- package/_esm/core/internal/cursor.js +32 -0
- package/_esm/core/internal/cursor.js.map +1 -1
- package/_esm/erc4337/UserOperation.js +1 -1
- package/_esm/erc4337/UserOperation.js.map +1 -1
- package/_esm/erc7821/Execute.js +76 -2
- package/_esm/erc7821/Execute.js.map +1 -1
- package/_esm/index.js +1 -1
- package/_esm/tempo/KeyAuthorization.js +21 -0
- package/_esm/tempo/KeyAuthorization.js.map +1 -1
- package/_esm/tempo/SignatureEnvelope.js +46 -13
- package/_esm/tempo/SignatureEnvelope.js.map +1 -1
- package/_esm/tempo/TxEnvelopeTempo.js +56 -2
- package/_esm/tempo/TxEnvelopeTempo.js.map +1 -1
- package/_esm/version.js +1 -1
- package/_esm/webauthn/Registration.js +2 -6
- package/_esm/webauthn/Registration.js.map +1 -1
- package/_types/core/AbiError.d.ts +51 -5
- package/_types/core/AbiError.d.ts.map +1 -1
- package/_types/core/AbiEvent.d.ts +4 -2
- package/_types/core/AbiEvent.d.ts.map +1 -1
- package/_types/core/AbiFunction.d.ts +48 -2
- package/_types/core/AbiFunction.d.ts.map +1 -1
- package/_types/core/Address.d.ts +17 -2
- package/_types/core/Address.d.ts.map +1 -1
- package/_types/core/Authorization.d.ts +24 -2
- package/_types/core/Authorization.d.ts.map +1 -1
- package/_types/core/Keystore.d.ts +31 -2
- package/_types/core/Keystore.d.ts.map +1 -1
- package/_types/core/Secp256k1.d.ts.map +1 -1
- package/_types/core/Signature.d.ts +1 -1
- package/_types/core/Signature.d.ts.map +1 -1
- package/_types/core/Siwe.d.ts +4 -0
- package/_types/core/Siwe.d.ts.map +1 -1
- package/_types/core/TxEnvelopeEip1559.d.ts.map +1 -1
- package/_types/core/TxEnvelopeEip2930.d.ts.map +1 -1
- package/_types/core/TxEnvelopeEip7702.d.ts +1 -1
- package/_types/core/TxEnvelopeEip7702.d.ts.map +1 -1
- package/_types/core/TxEnvelopeLegacy.d.ts.map +1 -1
- package/_types/core/TypedData.d.ts +3 -1
- package/_types/core/TypedData.d.ts.map +1 -1
- package/_types/core/Value.d.ts.map +1 -1
- package/_types/core/internal/abiParameters.d.ts +1 -1
- package/_types/core/internal/abiParameters.d.ts.map +1 -1
- package/_types/core/internal/cursor.d.ts +13 -0
- package/_types/core/internal/cursor.d.ts.map +1 -1
- package/_types/erc7821/Execute.d.ts +46 -1
- package/_types/erc7821/Execute.d.ts.map +1 -1
- package/_types/index.d.ts +1 -1
- package/_types/tempo/KeyAuthorization.d.ts +9 -3
- package/_types/tempo/KeyAuthorization.d.ts.map +1 -1
- package/_types/tempo/SignatureEnvelope.d.ts +1 -1
- package/_types/tempo/SignatureEnvelope.d.ts.map +1 -1
- package/_types/tempo/TxEnvelopeTempo.d.ts +30 -1
- package/_types/tempo/TxEnvelopeTempo.d.ts.map +1 -1
- package/_types/version.d.ts +1 -1
- package/_types/webauthn/Registration.d.ts +2 -0
- package/_types/webauthn/Registration.d.ts.map +1 -1
- package/core/AbiError.ts +81 -7
- package/core/AbiEvent.ts +50 -11
- package/core/AbiFunction.ts +76 -4
- package/core/Address.ts +18 -1
- package/core/Authorization.ts +47 -4
- package/core/Keystore.ts +40 -3
- package/core/Secp256k1.ts +5 -1
- package/core/Signature.ts +7 -2
- package/core/Siwe.ts +29 -3
- package/core/TxEnvelopeEip1559.ts +4 -1
- package/core/TxEnvelopeEip2930.ts +4 -1
- package/core/TxEnvelopeEip7702.ts +9 -2
- package/core/TxEnvelopeLegacy.ts +56 -10
- package/core/TypedData.ts +10 -9
- package/core/Value.ts +14 -3
- package/core/internal/abiParameters.ts +8 -2
- package/core/internal/cursor.ts +36 -0
- package/erc4337/UserOperation.ts +1 -1
- package/erc7821/Execute.ts +84 -3
- package/index.ts +1 -1
- package/package.json +1 -1
- package/tempo/KeyAuthorization.test.ts +91 -0
- package/tempo/KeyAuthorization.ts +32 -3
- package/tempo/SignatureEnvelope.test.ts +211 -27
- package/tempo/SignatureEnvelope.ts +55 -11
- package/tempo/TxEnvelopeTempo.test.ts +310 -0
- package/tempo/TxEnvelopeTempo.ts +64 -1
- package/version.ts +1 -1
- package/webauthn/Registration.ts +4 -6
|
@@ -66,6 +66,50 @@ describe('assert', () => {
|
|
|
66
66
|
)
|
|
67
67
|
})
|
|
68
68
|
|
|
69
|
+
test('invalid validity bound', () => {
|
|
70
|
+
const envelope = {
|
|
71
|
+
calls: [{ to: '0x0000000000000000000000000000000000000000' }],
|
|
72
|
+
chainId: 1,
|
|
73
|
+
} as const
|
|
74
|
+
expect(() =>
|
|
75
|
+
TxEnvelopeTempo.assert({
|
|
76
|
+
...envelope,
|
|
77
|
+
validBefore: 1700003600n as never,
|
|
78
|
+
}),
|
|
79
|
+
).toThrowErrorMatchingInlineSnapshot(
|
|
80
|
+
`[TxEnvelopeTempo.InvalidValidityBoundError: validBefore (1700003600n) must be a non-negative safe integer number.]`,
|
|
81
|
+
)
|
|
82
|
+
expect(() =>
|
|
83
|
+
TxEnvelopeTempo.assert({
|
|
84
|
+
...envelope,
|
|
85
|
+
validAfter: '0x6553f100' as never,
|
|
86
|
+
}),
|
|
87
|
+
).toThrowErrorMatchingInlineSnapshot(
|
|
88
|
+
`[TxEnvelopeTempo.InvalidValidityBoundError: validAfter ("0x6553f100") must be a non-negative safe integer number.]`,
|
|
89
|
+
)
|
|
90
|
+
expect(() =>
|
|
91
|
+
TxEnvelopeTempo.assert({ ...envelope, validBefore: -1 }),
|
|
92
|
+
).toThrowErrorMatchingInlineSnapshot(
|
|
93
|
+
`[TxEnvelopeTempo.InvalidValidityBoundError: validBefore (-1) must be a non-negative safe integer number.]`,
|
|
94
|
+
)
|
|
95
|
+
expect(() =>
|
|
96
|
+
TxEnvelopeTempo.assert({ ...envelope, validAfter: 1.5 }),
|
|
97
|
+
).toThrowErrorMatchingInlineSnapshot(
|
|
98
|
+
`[TxEnvelopeTempo.InvalidValidityBoundError: validAfter (1.5) must be a non-negative safe integer number.]`,
|
|
99
|
+
)
|
|
100
|
+
expect(() =>
|
|
101
|
+
TxEnvelopeTempo.assert({
|
|
102
|
+
...envelope,
|
|
103
|
+
validBefore: Number.MAX_SAFE_INTEGER + 1,
|
|
104
|
+
}),
|
|
105
|
+
).toThrowErrorMatchingInlineSnapshot(
|
|
106
|
+
`[TxEnvelopeTempo.InvalidValidityBoundError: validBefore (9007199254740992) must be a non-negative safe integer number.]`,
|
|
107
|
+
)
|
|
108
|
+
expect(() =>
|
|
109
|
+
TxEnvelopeTempo.assert({ ...envelope, validAfter: 0, validBefore: 1 }),
|
|
110
|
+
).not.toThrow()
|
|
111
|
+
})
|
|
112
|
+
|
|
69
113
|
test('invalid call address', () => {
|
|
70
114
|
expect(() =>
|
|
71
115
|
TxEnvelopeTempo.assert({
|
|
@@ -129,6 +173,93 @@ describe('assert', () => {
|
|
|
129
173
|
`[TransactionEnvelope.InvalidChainIdError: Chain ID "0" is invalid.]`,
|
|
130
174
|
)
|
|
131
175
|
})
|
|
176
|
+
|
|
177
|
+
test('invalid chain id (not a positive safe integer)', () => {
|
|
178
|
+
expect(() =>
|
|
179
|
+
TxEnvelopeTempo.assert({
|
|
180
|
+
calls: [{ to: '0x0000000000000000000000000000000000000000' }],
|
|
181
|
+
chainId: Number.NaN,
|
|
182
|
+
}),
|
|
183
|
+
).toThrowErrorMatchingInlineSnapshot(
|
|
184
|
+
`[TransactionEnvelope.InvalidChainIdError: Chain ID "NaN" is invalid.]`,
|
|
185
|
+
)
|
|
186
|
+
expect(() =>
|
|
187
|
+
TxEnvelopeTempo.assert({
|
|
188
|
+
calls: [{ to: '0x0000000000000000000000000000000000000000' }],
|
|
189
|
+
chainId: 1.5,
|
|
190
|
+
}),
|
|
191
|
+
).toThrowErrorMatchingInlineSnapshot(
|
|
192
|
+
`[TransactionEnvelope.InvalidChainIdError: Chain ID "1.5" is invalid.]`,
|
|
193
|
+
)
|
|
194
|
+
expect(() =>
|
|
195
|
+
TxEnvelopeTempo.assert({
|
|
196
|
+
calls: [{ to: '0x0000000000000000000000000000000000000000' }],
|
|
197
|
+
chainId: Number.MAX_SAFE_INTEGER + 1,
|
|
198
|
+
}),
|
|
199
|
+
).toThrowErrorMatchingInlineSnapshot(
|
|
200
|
+
`[TransactionEnvelope.InvalidChainIdError: Chain ID "9007199254740992" is invalid.]`,
|
|
201
|
+
)
|
|
202
|
+
expect(() =>
|
|
203
|
+
TxEnvelopeTempo.assert({
|
|
204
|
+
calls: [{ to: '0x0000000000000000000000000000000000000000' }],
|
|
205
|
+
chainId: '1' as never,
|
|
206
|
+
}),
|
|
207
|
+
).toThrowErrorMatchingInlineSnapshot(
|
|
208
|
+
`[TransactionEnvelope.InvalidChainIdError: Chain ID "1" is invalid.]`,
|
|
209
|
+
)
|
|
210
|
+
expect(() =>
|
|
211
|
+
TxEnvelopeTempo.assert({
|
|
212
|
+
calls: [{ to: '0x0000000000000000000000000000000000000000' }],
|
|
213
|
+
chainId: 1n as never,
|
|
214
|
+
}),
|
|
215
|
+
).toThrowErrorMatchingInlineSnapshot(
|
|
216
|
+
`[TransactionEnvelope.InvalidChainIdError: Chain ID "1" is invalid.]`,
|
|
217
|
+
)
|
|
218
|
+
})
|
|
219
|
+
|
|
220
|
+
test('invalid fee payer signature', () => {
|
|
221
|
+
const envelope = {
|
|
222
|
+
calls: [{ to: '0x0000000000000000000000000000000000000000' }],
|
|
223
|
+
chainId: 1,
|
|
224
|
+
} as const
|
|
225
|
+
const feePayerSignature = {
|
|
226
|
+
r: 1n,
|
|
227
|
+
s: 1n,
|
|
228
|
+
} as const
|
|
229
|
+
expect(() =>
|
|
230
|
+
TxEnvelopeTempo.assert({
|
|
231
|
+
...envelope,
|
|
232
|
+
feePayerSignature: { ...feePayerSignature, yParity: 2 },
|
|
233
|
+
}),
|
|
234
|
+
).toThrowErrorMatchingInlineSnapshot(
|
|
235
|
+
`[Signature.InvalidYParityError: Value \`2\` is an invalid y-parity value. Y-parity must be 0 or 1.]`,
|
|
236
|
+
)
|
|
237
|
+
expect(() =>
|
|
238
|
+
TxEnvelopeTempo.assert({
|
|
239
|
+
...envelope,
|
|
240
|
+
feePayerSignature: { ...feePayerSignature, yParity: 27 },
|
|
241
|
+
}),
|
|
242
|
+
).toThrowErrorMatchingInlineSnapshot(
|
|
243
|
+
`[Signature.InvalidYParityError: Value \`27\` is an invalid y-parity value. Y-parity must be 0 or 1.]`,
|
|
244
|
+
)
|
|
245
|
+
expect(() =>
|
|
246
|
+
TxEnvelopeTempo.assert({
|
|
247
|
+
...envelope,
|
|
248
|
+
feePayerSignature: feePayerSignature as never,
|
|
249
|
+
}),
|
|
250
|
+
).toThrowErrorMatchingInlineSnapshot(
|
|
251
|
+
`[Signature.MissingPropertiesError: Signature \`{"r":"1#__bigint","s":"1#__bigint"}\` is missing either an \`r\`, \`s\`, or \`yParity\` property.]`,
|
|
252
|
+
)
|
|
253
|
+
expect(() =>
|
|
254
|
+
TxEnvelopeTempo.assert({
|
|
255
|
+
...envelope,
|
|
256
|
+
feePayerSignature: { ...feePayerSignature, yParity: 1 },
|
|
257
|
+
}),
|
|
258
|
+
).not.toThrow()
|
|
259
|
+
expect(() =>
|
|
260
|
+
TxEnvelopeTempo.assert({ ...envelope, feePayerSignature: null }),
|
|
261
|
+
).not.toThrow()
|
|
262
|
+
})
|
|
132
263
|
})
|
|
133
264
|
|
|
134
265
|
describe('deserialize', () => {
|
|
@@ -818,6 +949,19 @@ describe('from', () => {
|
|
|
818
949
|
expect(envelope.from).toBe(Address.checksum(hexAddr))
|
|
819
950
|
})
|
|
820
951
|
|
|
952
|
+
test('invalid validity bound', () => {
|
|
953
|
+
expect(() =>
|
|
954
|
+
TxEnvelopeTempo.from({
|
|
955
|
+
calls: [{ to: '0x0000000000000000000000000000000000000000' }],
|
|
956
|
+
chainId: 1,
|
|
957
|
+
validAfter: 1700000000n as never,
|
|
958
|
+
validBefore: 1700003600n as never,
|
|
959
|
+
}),
|
|
960
|
+
).toThrowErrorMatchingInlineSnapshot(
|
|
961
|
+
`[TxEnvelopeTempo.InvalidValidityBoundError: validBefore (1700003600n) must be a non-negative safe integer number.]`,
|
|
962
|
+
)
|
|
963
|
+
})
|
|
964
|
+
|
|
821
965
|
test('options: signature', () => {
|
|
822
966
|
const envelope = TxEnvelopeTempo.from(
|
|
823
967
|
{
|
|
@@ -954,6 +1098,23 @@ describe('from', () => {
|
|
|
954
1098
|
}
|
|
955
1099
|
`)
|
|
956
1100
|
})
|
|
1101
|
+
|
|
1102
|
+
test('invalid fee payer signature', () => {
|
|
1103
|
+
expect(() =>
|
|
1104
|
+
TxEnvelopeTempo.from({
|
|
1105
|
+
calls: [{}],
|
|
1106
|
+
chainId: 1,
|
|
1107
|
+
feePayerSignature: {
|
|
1108
|
+
r: 1n,
|
|
1109
|
+
s: 1n,
|
|
1110
|
+
yParity: 2,
|
|
1111
|
+
},
|
|
1112
|
+
nonce: 0n,
|
|
1113
|
+
}),
|
|
1114
|
+
).toThrowErrorMatchingInlineSnapshot(
|
|
1115
|
+
`[Signature.InvalidYParityError: Value \`2\` is an invalid y-parity value. Y-parity must be 0 or 1.]`,
|
|
1116
|
+
)
|
|
1117
|
+
})
|
|
957
1118
|
})
|
|
958
1119
|
|
|
959
1120
|
describe('serialize', () => {
|
|
@@ -998,6 +1159,40 @@ describe('serialize', () => {
|
|
|
998
1159
|
)
|
|
999
1160
|
})
|
|
1000
1161
|
|
|
1162
|
+
test('validBefore and validAfter', () => {
|
|
1163
|
+
const transaction = {
|
|
1164
|
+
chainId: 1,
|
|
1165
|
+
calls: [{}],
|
|
1166
|
+
nonce: 0n,
|
|
1167
|
+
} as const
|
|
1168
|
+
expect(
|
|
1169
|
+
TxEnvelopeTempo.serialize({
|
|
1170
|
+
...transaction,
|
|
1171
|
+
validAfter: 1700000000,
|
|
1172
|
+
validBefore: 1700003600,
|
|
1173
|
+
}),
|
|
1174
|
+
).toMatchInlineSnapshot(
|
|
1175
|
+
`"0x76d901808080c4c3808080c08080846553ff10846553f1008080c0"`,
|
|
1176
|
+
)
|
|
1177
|
+
expect(() =>
|
|
1178
|
+
TxEnvelopeTempo.serialize({
|
|
1179
|
+
...transaction,
|
|
1180
|
+
validAfter: 1700000000n as never,
|
|
1181
|
+
validBefore: 1700003600n as never,
|
|
1182
|
+
}),
|
|
1183
|
+
).toThrowErrorMatchingInlineSnapshot(
|
|
1184
|
+
`[TxEnvelopeTempo.InvalidValidityBoundError: validBefore (1700003600n) must be a non-negative safe integer number.]`,
|
|
1185
|
+
)
|
|
1186
|
+
expect(() =>
|
|
1187
|
+
TxEnvelopeTempo.serialize({
|
|
1188
|
+
...transaction,
|
|
1189
|
+
validBefore: '0x6553ff10' as never,
|
|
1190
|
+
}),
|
|
1191
|
+
).toThrowErrorMatchingInlineSnapshot(
|
|
1192
|
+
`[TxEnvelopeTempo.InvalidValidityBoundError: validBefore ("0x6553ff10") must be a non-negative safe integer number.]`,
|
|
1193
|
+
)
|
|
1194
|
+
})
|
|
1195
|
+
|
|
1001
1196
|
test('multiple calls', () => {
|
|
1002
1197
|
const transaction = TxEnvelopeTempo.from({
|
|
1003
1198
|
chainId: 1,
|
|
@@ -1350,6 +1545,47 @@ describe('serialize', () => {
|
|
|
1350
1545
|
)
|
|
1351
1546
|
})
|
|
1352
1547
|
|
|
1548
|
+
test('with feePayerSignature (invalid yParity)', () => {
|
|
1549
|
+
const transaction = {
|
|
1550
|
+
calls: [{ to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8' }],
|
|
1551
|
+
chainId: 1,
|
|
1552
|
+
nonce: 0n,
|
|
1553
|
+
} as const
|
|
1554
|
+
const feePayerSignature = {
|
|
1555
|
+
r: 1n,
|
|
1556
|
+
s: 1n,
|
|
1557
|
+
} as const
|
|
1558
|
+
expect(
|
|
1559
|
+
TxEnvelopeTempo.serialize(transaction, {
|
|
1560
|
+
feePayerSignature: { ...feePayerSignature, yParity: 1 },
|
|
1561
|
+
}),
|
|
1562
|
+
).toMatchInlineSnapshot(
|
|
1563
|
+
`"0x76e801808080d8d79470997970c51812dc3a010c7d01b50e0d17dc79c88080c08080808080c3010101c0"`,
|
|
1564
|
+
)
|
|
1565
|
+
expect(() =>
|
|
1566
|
+
TxEnvelopeTempo.serialize(transaction, {
|
|
1567
|
+
feePayerSignature: { ...feePayerSignature, yParity: 2 },
|
|
1568
|
+
}),
|
|
1569
|
+
).toThrowErrorMatchingInlineSnapshot(
|
|
1570
|
+
`[Signature.InvalidYParityError: Value \`2\` is an invalid y-parity value. Y-parity must be 0 or 1.]`,
|
|
1571
|
+
)
|
|
1572
|
+
expect(() =>
|
|
1573
|
+
TxEnvelopeTempo.serialize(transaction, {
|
|
1574
|
+
feePayerSignature: { ...feePayerSignature, yParity: 27 },
|
|
1575
|
+
}),
|
|
1576
|
+
).toThrowErrorMatchingInlineSnapshot(
|
|
1577
|
+
`[Signature.InvalidYParityError: Value \`27\` is an invalid y-parity value. Y-parity must be 0 or 1.]`,
|
|
1578
|
+
)
|
|
1579
|
+
expect(() =>
|
|
1580
|
+
TxEnvelopeTempo.serialize({
|
|
1581
|
+
...transaction,
|
|
1582
|
+
feePayerSignature: { ...feePayerSignature, yParity: 2 },
|
|
1583
|
+
}),
|
|
1584
|
+
).toThrowErrorMatchingInlineSnapshot(
|
|
1585
|
+
`[Signature.InvalidYParityError: Value \`2\` is an invalid y-parity value. Y-parity must be 0 or 1.]`,
|
|
1586
|
+
)
|
|
1587
|
+
})
|
|
1588
|
+
|
|
1353
1589
|
test('format: feePayer', () => {
|
|
1354
1590
|
const transaction = TxEnvelopeTempo.from({
|
|
1355
1591
|
chainId: 1,
|
|
@@ -1475,6 +1711,24 @@ describe('hash', () => {
|
|
|
1475
1711
|
})
|
|
1476
1712
|
})
|
|
1477
1713
|
|
|
1714
|
+
test('invalid fee payer signature', () => {
|
|
1715
|
+
expect(() =>
|
|
1716
|
+
TxEnvelopeTempo.hash({
|
|
1717
|
+
calls: [{ to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8' }],
|
|
1718
|
+
chainId: 1,
|
|
1719
|
+
feePayerSignature: {
|
|
1720
|
+
r: 1n,
|
|
1721
|
+
s: 1n,
|
|
1722
|
+
yParity: 2,
|
|
1723
|
+
},
|
|
1724
|
+
nonce: 0n,
|
|
1725
|
+
type: 'tempo',
|
|
1726
|
+
} as never),
|
|
1727
|
+
).toThrowErrorMatchingInlineSnapshot(
|
|
1728
|
+
`[Signature.InvalidYParityError: Value \`2\` is an invalid y-parity value. Y-parity must be 0 or 1.]`,
|
|
1729
|
+
)
|
|
1730
|
+
})
|
|
1731
|
+
|
|
1478
1732
|
test('presign', () => {
|
|
1479
1733
|
const transaction = TxEnvelopeTempo.from({
|
|
1480
1734
|
chainId: 1,
|
|
@@ -1491,6 +1745,23 @@ describe('hash', () => {
|
|
|
1491
1745
|
`"0xe1222a45806457acbe3a13940aae4c34f3180659fa16613b5a45dc183adae07c"`,
|
|
1492
1746
|
)
|
|
1493
1747
|
})
|
|
1748
|
+
|
|
1749
|
+
test('invalid validity bound', () => {
|
|
1750
|
+
expect(() =>
|
|
1751
|
+
TxEnvelopeTempo.hash(
|
|
1752
|
+
{
|
|
1753
|
+
calls: [{ to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8' }],
|
|
1754
|
+
chainId: 1,
|
|
1755
|
+
nonce: 0n,
|
|
1756
|
+
type: 'tempo',
|
|
1757
|
+
validBefore: 1700003600n as never,
|
|
1758
|
+
},
|
|
1759
|
+
{ presign: true },
|
|
1760
|
+
),
|
|
1761
|
+
).toThrowErrorMatchingInlineSnapshot(
|
|
1762
|
+
`[TxEnvelopeTempo.InvalidValidityBoundError: validBefore (1700003600n) must be a non-negative safe integer number.]`,
|
|
1763
|
+
)
|
|
1764
|
+
})
|
|
1494
1765
|
})
|
|
1495
1766
|
|
|
1496
1767
|
describe('encodeForSigning', () => {
|
|
@@ -1592,6 +1863,20 @@ describe('getSignPayload', () => {
|
|
|
1592
1863
|
})
|
|
1593
1864
|
expect(hashTempo).toBe(hashHex)
|
|
1594
1865
|
})
|
|
1866
|
+
|
|
1867
|
+
test('invalid validity bound', () => {
|
|
1868
|
+
expect(() =>
|
|
1869
|
+
TxEnvelopeTempo.getSignPayload({
|
|
1870
|
+
calls: [{ to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8' }],
|
|
1871
|
+
chainId: 1,
|
|
1872
|
+
nonce: 0n,
|
|
1873
|
+
type: 'tempo',
|
|
1874
|
+
validBefore: 1700003600n as never,
|
|
1875
|
+
}),
|
|
1876
|
+
).toThrowErrorMatchingInlineSnapshot(
|
|
1877
|
+
`[TxEnvelopeTempo.InvalidValidityBoundError: validBefore (1700003600n) must be a non-negative safe integer number.]`,
|
|
1878
|
+
)
|
|
1879
|
+
})
|
|
1595
1880
|
})
|
|
1596
1881
|
|
|
1597
1882
|
describe('getFeePayerSignPayload', () => {
|
|
@@ -1684,6 +1969,20 @@ describe('validate', () => {
|
|
|
1684
1969
|
).toBe(false)
|
|
1685
1970
|
})
|
|
1686
1971
|
|
|
1972
|
+
test('invalid (fee payer signature)', () => {
|
|
1973
|
+
expect(
|
|
1974
|
+
TxEnvelopeTempo.validate({
|
|
1975
|
+
calls: [{ to: '0x0000000000000000000000000000000000000000' }],
|
|
1976
|
+
chainId: 1,
|
|
1977
|
+
feePayerSignature: {
|
|
1978
|
+
r: 1n,
|
|
1979
|
+
s: 1n,
|
|
1980
|
+
yParity: 2,
|
|
1981
|
+
},
|
|
1982
|
+
}),
|
|
1983
|
+
).toBe(false)
|
|
1984
|
+
})
|
|
1985
|
+
|
|
1687
1986
|
test('invalid (validity window)', () => {
|
|
1688
1987
|
expect(
|
|
1689
1988
|
TxEnvelopeTempo.validate({
|
|
@@ -1694,4 +1993,15 @@ describe('validate', () => {
|
|
|
1694
1993
|
}),
|
|
1695
1994
|
).toBe(false)
|
|
1696
1995
|
})
|
|
1996
|
+
|
|
1997
|
+
test('invalid (validity bound)', () => {
|
|
1998
|
+
expect(
|
|
1999
|
+
TxEnvelopeTempo.validate({
|
|
2000
|
+
calls: [{ to: '0x0000000000000000000000000000000000000000' }],
|
|
2001
|
+
chainId: 1,
|
|
2002
|
+
validBefore: 100n as never,
|
|
2003
|
+
validAfter: 200n as never,
|
|
2004
|
+
}),
|
|
2005
|
+
).toBe(false)
|
|
2006
|
+
})
|
|
1697
2007
|
})
|
package/tempo/TxEnvelopeTempo.ts
CHANGED
|
@@ -178,6 +178,7 @@ export function assert(envelope: PartialBy<TxEnvelopeTempo, 'type'>) {
|
|
|
178
178
|
const {
|
|
179
179
|
calls,
|
|
180
180
|
chainId,
|
|
181
|
+
feePayerSignature,
|
|
181
182
|
maxFeePerGas,
|
|
182
183
|
maxPriorityFeePerGas,
|
|
183
184
|
validBefore,
|
|
@@ -187,6 +188,18 @@ export function assert(envelope: PartialBy<TxEnvelopeTempo, 'type'>) {
|
|
|
187
188
|
// Calls must not be empty
|
|
188
189
|
if (!calls || calls.length === 0) throw new CallsEmptyError()
|
|
189
190
|
|
|
191
|
+
// validBefore and validAfter must be non-negative safe integers if set
|
|
192
|
+
for (const [name, value] of [
|
|
193
|
+
['validBefore', validBefore],
|
|
194
|
+
['validAfter', validAfter],
|
|
195
|
+
] as const)
|
|
196
|
+
if (
|
|
197
|
+
value !== undefined &&
|
|
198
|
+
value !== null &&
|
|
199
|
+
!(Number.isSafeInteger(value) && value >= 0)
|
|
200
|
+
)
|
|
201
|
+
throw new InvalidValidityBoundError({ name, value })
|
|
202
|
+
|
|
190
203
|
// validBefore must be greater than validAfter if both are set
|
|
191
204
|
if (
|
|
192
205
|
typeof validBefore === 'number' &&
|
|
@@ -205,7 +218,10 @@ export function assert(envelope: PartialBy<TxEnvelopeTempo, 'type'>) {
|
|
|
205
218
|
if (call.to) Address.assert(call.to, { strict: false })
|
|
206
219
|
|
|
207
220
|
// Validate chain ID
|
|
208
|
-
if (
|
|
221
|
+
if (
|
|
222
|
+
typeof chainId !== 'undefined' &&
|
|
223
|
+
(!Number.isSafeInteger(chainId) || chainId <= 0)
|
|
224
|
+
)
|
|
209
225
|
throw new TransactionEnvelope.InvalidChainIdError({ chainId })
|
|
210
226
|
|
|
211
227
|
// Validate max fee per gas
|
|
@@ -223,13 +239,19 @@ export function assert(envelope: PartialBy<TxEnvelopeTempo, 'type'>) {
|
|
|
223
239
|
maxFeePerGas,
|
|
224
240
|
maxPriorityFeePerGas,
|
|
225
241
|
})
|
|
242
|
+
|
|
243
|
+
// Validate fee payer signature
|
|
244
|
+
if (feePayerSignature)
|
|
245
|
+
Signature.assert(feePayerSignature, { recovered: true })
|
|
226
246
|
}
|
|
227
247
|
|
|
228
248
|
export declare namespace assert {
|
|
229
249
|
type ErrorType =
|
|
230
250
|
| Address.assert.ErrorType
|
|
231
251
|
| CallsEmptyError
|
|
252
|
+
| InvalidValidityBoundError
|
|
232
253
|
| InvalidValidityWindowError
|
|
254
|
+
| Signature.assert.ErrorType
|
|
233
255
|
| Errors.GlobalErrorType
|
|
234
256
|
}
|
|
235
257
|
|
|
@@ -708,6 +730,7 @@ export function serialize(
|
|
|
708
730
|
// No fee payer involvement — omit from the envelope.
|
|
709
731
|
if (!feePayerSignature) return '0x'
|
|
710
732
|
// Fee payer has signed — encode the signature as an RLP tuple.
|
|
733
|
+
Signature.assert(feePayerSignature, { recovered: true })
|
|
711
734
|
return Signature.toTuple(feePayerSignature)
|
|
712
735
|
})()
|
|
713
736
|
|
|
@@ -1073,6 +1096,46 @@ export class CallsEmptyError extends Errors.BaseError {
|
|
|
1073
1096
|
}
|
|
1074
1097
|
}
|
|
1075
1098
|
|
|
1099
|
+
/**
|
|
1100
|
+
* Thrown when validBefore or validAfter is not a non-negative safe integer number.
|
|
1101
|
+
*
|
|
1102
|
+
* @example
|
|
1103
|
+
* ```ts twoslash
|
|
1104
|
+
* import { Address } from 'ox'
|
|
1105
|
+
* import { TxEnvelopeTempo } from 'ox/tempo'
|
|
1106
|
+
*
|
|
1107
|
+
* TxEnvelopeTempo.assert({
|
|
1108
|
+
* calls: [
|
|
1109
|
+
* {
|
|
1110
|
+
* to: Address.from(
|
|
1111
|
+
* '0x0000000000000000000000000000000000000000'
|
|
1112
|
+
* )
|
|
1113
|
+
* }
|
|
1114
|
+
* ],
|
|
1115
|
+
* chainId: 1,
|
|
1116
|
+
* validBefore: -1
|
|
1117
|
+
* })
|
|
1118
|
+
* // @error: TxEnvelopeTempo.InvalidValidityBoundError: validBefore (-1) must be a non-negative safe integer number.
|
|
1119
|
+
* ```
|
|
1120
|
+
*/
|
|
1121
|
+
export class InvalidValidityBoundError extends Errors.BaseError {
|
|
1122
|
+
override readonly name = 'TxEnvelopeTempo.InvalidValidityBoundError'
|
|
1123
|
+
constructor({
|
|
1124
|
+
name,
|
|
1125
|
+
value,
|
|
1126
|
+
}: {
|
|
1127
|
+
name: 'validAfter' | 'validBefore'
|
|
1128
|
+
value: unknown
|
|
1129
|
+
}) {
|
|
1130
|
+
const value_ = (() => {
|
|
1131
|
+
if (typeof value === 'bigint') return `${value}n`
|
|
1132
|
+
if (typeof value === 'string') return `"${value}"`
|
|
1133
|
+
return String(value)
|
|
1134
|
+
})()
|
|
1135
|
+
super(`${name} (${value_}) must be a non-negative safe integer number.`)
|
|
1136
|
+
}
|
|
1137
|
+
}
|
|
1138
|
+
|
|
1076
1139
|
/**
|
|
1077
1140
|
* Thrown when validBefore is not greater than validAfter.
|
|
1078
1141
|
*
|
package/version.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/** @internal */
|
|
2
|
-
export const version = '0.14.
|
|
2
|
+
export const version = '0.14.66'
|
package/webauthn/Registration.ts
CHANGED
|
@@ -30,7 +30,9 @@ export type Response<serialized extends boolean = false> = {
|
|
|
30
30
|
credential: Credential_.Credential<serialized>
|
|
31
31
|
counter: number
|
|
32
32
|
userVerified?: true | undefined
|
|
33
|
+
/** Whether the credential is currently backed up (BS flag). */
|
|
33
34
|
backedUp?: boolean | undefined
|
|
35
|
+
/** `'multiDevice'` if the credential is backup eligible (BE flag), otherwise `'singleDevice'`. */
|
|
34
36
|
deviceType?: 'multiDevice' | 'singleDevice' | undefined
|
|
35
37
|
}
|
|
36
38
|
|
|
@@ -747,12 +749,8 @@ export function verify(options: verify.Options): verify.ReturnType {
|
|
|
747
749
|
},
|
|
748
750
|
counter,
|
|
749
751
|
...(uv ? { userVerified: true as const } : {}),
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
? {
|
|
753
|
-
deviceType: bs ? ('multiDevice' as const) : ('singleDevice' as const),
|
|
754
|
-
}
|
|
755
|
-
: {}),
|
|
752
|
+
backedUp: bs,
|
|
753
|
+
deviceType: be ? 'multiDevice' : 'singleDevice',
|
|
756
754
|
}
|
|
757
755
|
}
|
|
758
756
|
|