ox 0.12.2 → 0.12.4
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 +18 -0
- package/CoseKey/package.json +6 -0
- package/_cjs/core/Cbor.js +58 -0
- package/_cjs/core/Cbor.js.map +1 -1
- package/_cjs/core/CoseKey.js +41 -0
- package/_cjs/core/CoseKey.js.map +1 -0
- package/_cjs/core/WebAuthnP256.js +24 -5
- package/_cjs/core/WebAuthnP256.js.map +1 -1
- package/_cjs/index.js +3 -2
- package/_cjs/index.js.map +1 -1
- package/_cjs/tempo/TxEnvelopeTempo.js +19 -1
- package/_cjs/tempo/TxEnvelopeTempo.js.map +1 -1
- package/_cjs/version.js +1 -1
- package/_esm/core/Cbor.js +59 -0
- package/_esm/core/Cbor.js.map +1 -1
- package/_esm/core/CoseKey.js +74 -0
- package/_esm/core/CoseKey.js.map +1 -0
- package/_esm/core/WebAuthnP256.js +75 -5
- package/_esm/core/WebAuthnP256.js.map +1 -1
- package/_esm/index.js +32 -0
- package/_esm/index.js.map +1 -1
- package/_esm/tempo/TxEnvelopeTempo.js +20 -1
- package/_esm/tempo/TxEnvelopeTempo.js.map +1 -1
- package/_esm/version.js +1 -1
- package/_types/core/Cbor.d.ts.map +1 -1
- package/_types/core/CoseKey.d.ts +56 -0
- package/_types/core/CoseKey.d.ts.map +1 -0
- package/_types/core/WebAuthnP256.d.ts +71 -0
- package/_types/core/WebAuthnP256.d.ts.map +1 -1
- package/_types/index.d.ts +32 -0
- package/_types/index.d.ts.map +1 -1
- package/_types/tempo/TxEnvelopeTempo.d.ts.map +1 -1
- package/_types/version.d.ts +1 -1
- package/core/Cbor.ts +64 -0
- package/core/CoseKey.ts +93 -0
- package/core/WebAuthnP256.ts +113 -4
- package/index.ts +32 -1
- package/package.json +6 -1
- package/tempo/TxEnvelopeTempo.test.ts +6 -0
- package/tempo/TxEnvelopeTempo.ts +22 -2
- package/version.ts +1 -1
|
@@ -7,6 +7,7 @@ import * as TxEnvelopeTempo from './TxEnvelopeTempo.js'
|
|
|
7
7
|
|
|
8
8
|
const privateKey =
|
|
9
9
|
'0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80'
|
|
10
|
+
const address = Address.fromPublicKey(Secp256k1.getPublicKey({ privateKey }))
|
|
10
11
|
|
|
11
12
|
describe('assert', () => {
|
|
12
13
|
test('empty calls list', () => {
|
|
@@ -340,6 +341,7 @@ describe('deserialize', () => {
|
|
|
340
341
|
})
|
|
341
342
|
expect(TxEnvelopeTempo.deserialize(serialized)).toEqual({
|
|
342
343
|
...transaction,
|
|
344
|
+
from: address,
|
|
343
345
|
signature: { signature, type: 'secp256k1' },
|
|
344
346
|
})
|
|
345
347
|
})
|
|
@@ -354,6 +356,7 @@ describe('deserialize', () => {
|
|
|
354
356
|
})
|
|
355
357
|
expect(TxEnvelopeTempo.deserialize(serialized)).toEqual({
|
|
356
358
|
...transaction,
|
|
359
|
+
from: address,
|
|
357
360
|
signature: { signature, type: 'secp256k1' },
|
|
358
361
|
})
|
|
359
362
|
})
|
|
@@ -377,6 +380,7 @@ describe('deserialize', () => {
|
|
|
377
380
|
delete signature.yParity
|
|
378
381
|
expect(TxEnvelopeTempo.deserialize(serialized)).toEqual({
|
|
379
382
|
...transaction,
|
|
383
|
+
from: Address.fromPublicKey(publicKey),
|
|
380
384
|
signature: { prehash: true, publicKey, signature, type: 'p256' },
|
|
381
385
|
})
|
|
382
386
|
})
|
|
@@ -417,6 +421,7 @@ describe('deserialize', () => {
|
|
|
417
421
|
]).slice(2)}` as const
|
|
418
422
|
const deserialized = TxEnvelopeTempo.deserialize(serialized)
|
|
419
423
|
expect(deserialized.feePayerSignature).toBe(null)
|
|
424
|
+
expect(deserialized.from).toBe('0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266')
|
|
420
425
|
})
|
|
421
426
|
|
|
422
427
|
test('feePayerSignature with signature tuple', () => {
|
|
@@ -1174,6 +1179,7 @@ describe('serialize', () => {
|
|
|
1174
1179
|
delete signature.yParity
|
|
1175
1180
|
expect(TxEnvelopeTempo.deserialize(serialized)).toEqual({
|
|
1176
1181
|
...transaction,
|
|
1182
|
+
from: Address.fromPublicKey(publicKey),
|
|
1177
1183
|
nonceKey: 0n,
|
|
1178
1184
|
signature: { prehash: true, publicKey, signature, type: 'p256' },
|
|
1179
1185
|
})
|
package/tempo/TxEnvelopeTempo.ts
CHANGED
|
@@ -351,9 +351,11 @@ export function deserialize(serialized: Serialized): Compute<TxEnvelopeTempo> {
|
|
|
351
351
|
if (
|
|
352
352
|
feePayerSignatureOrSender === '0x00' ||
|
|
353
353
|
Address.validate(feePayerSignatureOrSender)
|
|
354
|
-
)
|
|
354
|
+
) {
|
|
355
355
|
transaction.feePayerSignature = null
|
|
356
|
-
|
|
356
|
+
if (Address.validate(feePayerSignatureOrSender))
|
|
357
|
+
transaction.from = feePayerSignatureOrSender
|
|
358
|
+
} else
|
|
357
359
|
transaction.feePayerSignature = Signature.fromTuple(
|
|
358
360
|
feePayerSignatureOrSender as never,
|
|
359
361
|
)
|
|
@@ -373,6 +375,24 @@ export function deserialize(serialized: Serialized): Compute<TxEnvelopeTempo> {
|
|
|
373
375
|
signature: signatureEnvelope,
|
|
374
376
|
}
|
|
375
377
|
|
|
378
|
+
// Recover sender address from the signature if not already set.
|
|
379
|
+
if (!transaction.from && signatureEnvelope) {
|
|
380
|
+
try {
|
|
381
|
+
if (signatureEnvelope.type === 'keychain')
|
|
382
|
+
transaction.from = signatureEnvelope.userAddress
|
|
383
|
+
else if (
|
|
384
|
+
signatureEnvelope.type === 'p256' ||
|
|
385
|
+
signatureEnvelope.type === 'webAuthn'
|
|
386
|
+
)
|
|
387
|
+
transaction.from = Address.fromPublicKey(signatureEnvelope.publicKey)
|
|
388
|
+
else if (signatureEnvelope.type === 'secp256k1')
|
|
389
|
+
transaction.from = Secp256k1.recoverAddress({
|
|
390
|
+
payload: getSignPayload(from(transaction)),
|
|
391
|
+
signature: signatureEnvelope.signature,
|
|
392
|
+
})
|
|
393
|
+
} catch {}
|
|
394
|
+
}
|
|
395
|
+
|
|
376
396
|
assert(transaction)
|
|
377
397
|
|
|
378
398
|
return transaction
|
package/version.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/** @internal */
|
|
2
|
-
export const version = '0.12.
|
|
2
|
+
export const version = '0.12.4'
|