ox 0.9.16 → 0.10.0
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 +27 -0
- package/README.md +4 -4
- package/TxEnvelope/package.json +6 -0
- package/TxEnvelopeEip1559/package.json +6 -0
- package/TxEnvelopeEip2930/package.json +6 -0
- package/TxEnvelopeEip4844/package.json +6 -0
- package/TxEnvelopeEip7702/package.json +6 -0
- package/TxEnvelopeLegacy/package.json +6 -0
- package/_cjs/core/{TransactionEnvelope.js → TxEnvelope.js} +1 -1
- package/_cjs/core/TxEnvelope.js.map +1 -0
- package/_cjs/core/{TransactionEnvelopeEip1559.js → TxEnvelopeEip1559.js} +2 -2
- package/_cjs/core/TxEnvelopeEip1559.js.map +1 -0
- package/_cjs/core/{TransactionEnvelopeEip2930.js → TxEnvelopeEip2930.js} +2 -2
- package/_cjs/core/TxEnvelopeEip2930.js.map +1 -0
- package/_cjs/core/{TransactionEnvelopeEip4844.js → TxEnvelopeEip4844.js} +4 -4
- package/_cjs/core/TxEnvelopeEip4844.js.map +1 -0
- package/_cjs/core/{TransactionEnvelopeEip7702.js → TxEnvelopeEip7702.js} +4 -4
- package/_cjs/core/TxEnvelopeEip7702.js.map +1 -0
- package/_cjs/core/{TransactionEnvelopeLegacy.js → TxEnvelopeLegacy.js} +2 -2
- package/_cjs/core/TxEnvelopeLegacy.js.map +1 -0
- package/_cjs/core/WebAuthnP256.js +1 -1
- package/_cjs/core/WebAuthnP256.js.map +1 -1
- package/_cjs/erc8021/Attribution.js +36 -6
- package/_cjs/erc8021/Attribution.js.map +1 -1
- package/_cjs/index.docs.js +1 -0
- package/_cjs/index.docs.js.map +1 -1
- package/_cjs/index.js +7 -7
- package/_cjs/index.js.map +1 -1
- package/_cjs/tempo/AuthorizationTempo.js +101 -0
- package/_cjs/tempo/AuthorizationTempo.js.map +1 -0
- package/_cjs/tempo/KeyAuthorization.js +123 -0
- package/_cjs/tempo/KeyAuthorization.js.map +1 -0
- package/_cjs/tempo/PoolId.js +10 -0
- package/_cjs/tempo/PoolId.js.map +1 -0
- package/_cjs/tempo/SignatureEnvelope.js +394 -0
- package/_cjs/tempo/SignatureEnvelope.js.map +1 -0
- package/_cjs/tempo/Tick.js +77 -0
- package/_cjs/tempo/Tick.js.map +1 -0
- package/_cjs/tempo/TokenId.js +28 -0
- package/_cjs/tempo/TokenId.js.map +1 -0
- package/_cjs/tempo/TokenRole.js +26 -0
- package/_cjs/tempo/TokenRole.js.map +1 -0
- package/_cjs/tempo/Transaction.js +80 -0
- package/_cjs/tempo/Transaction.js.map +1 -0
- package/_cjs/tempo/TransactionReceipt.js +26 -0
- package/_cjs/tempo/TransactionReceipt.js.map +1 -0
- package/_cjs/tempo/TransactionRequest.js +53 -0
- package/_cjs/tempo/TransactionRequest.js.map +1 -0
- package/_cjs/tempo/TxEnvelopeTempo.js +267 -0
- package/_cjs/tempo/TxEnvelopeTempo.js.map +1 -0
- package/_cjs/tempo/index.js +15 -0
- package/_cjs/tempo/index.js.map +1 -0
- package/_cjs/version.js +1 -1
- package/_esm/core/Blobs.js +8 -8
- package/_esm/core/{TransactionEnvelope.js → TxEnvelope.js} +11 -11
- package/_esm/core/TxEnvelope.js.map +1 -0
- package/_esm/core/{TransactionEnvelopeEip1559.js → TxEnvelopeEip1559.js} +42 -42
- package/_esm/core/TxEnvelopeEip1559.js.map +1 -0
- package/_esm/core/{TransactionEnvelopeEip2930.js → TxEnvelopeEip2930.js} +43 -43
- package/_esm/core/TxEnvelopeEip2930.js.map +1 -0
- package/_esm/core/{TransactionEnvelopeEip4844.js → TxEnvelopeEip4844.js} +42 -42
- package/_esm/core/TxEnvelopeEip4844.js.map +1 -0
- package/_esm/core/{TransactionEnvelopeEip7702.js → TxEnvelopeEip7702.js} +40 -40
- package/_esm/core/TxEnvelopeEip7702.js.map +1 -0
- package/_esm/core/{TransactionEnvelopeLegacy.js → TxEnvelopeLegacy.js} +42 -42
- package/_esm/core/TxEnvelopeLegacy.js.map +1 -0
- package/_esm/core/WebAuthnP256.js +1 -1
- package/_esm/core/WebAuthnP256.js.map +1 -1
- package/_esm/erc8021/Attribution.js +58 -13
- package/_esm/erc8021/Attribution.js.map +1 -1
- package/_esm/index.docs.js +1 -0
- package/_esm/index.docs.js.map +1 -1
- package/_esm/index.js +192 -192
- package/_esm/index.js.map +1 -1
- package/_esm/tempo/AuthorizationTempo.js +664 -0
- package/_esm/tempo/AuthorizationTempo.js.map +1 -0
- package/_esm/tempo/KeyAuthorization.js +426 -0
- package/_esm/tempo/KeyAuthorization.js.map +1 -0
- package/_esm/tempo/PoolId.js +28 -0
- package/_esm/tempo/PoolId.js.map +1 -0
- package/_esm/tempo/SignatureEnvelope.js +660 -0
- package/_esm/tempo/SignatureEnvelope.js.map +1 -0
- package/_esm/tempo/Tick.js +147 -0
- package/_esm/tempo/Tick.js.map +1 -0
- package/_esm/tempo/TokenId.js +71 -0
- package/_esm/tempo/TokenId.js.map +1 -0
- package/_esm/tempo/TokenRole.js +40 -0
- package/_esm/tempo/TokenRole.js.map +1 -0
- package/_esm/tempo/Transaction.js +167 -0
- package/_esm/tempo/Transaction.js.map +1 -0
- package/_esm/tempo/TransactionReceipt.js +138 -0
- package/_esm/tempo/TransactionReceipt.js.map +1 -0
- package/_esm/tempo/TransactionRequest.js +99 -0
- package/_esm/tempo/TransactionRequest.js.map +1 -0
- package/_esm/tempo/TxEnvelopeTempo.js +607 -0
- package/_esm/tempo/TxEnvelopeTempo.js.map +1 -0
- package/_esm/tempo/index.js +298 -0
- package/_esm/tempo/index.js.map +1 -0
- package/_esm/version.js +1 -1
- package/_types/core/Blobs.d.ts +8 -8
- package/_types/core/{TransactionEnvelope.d.ts → TxEnvelope.d.ts} +11 -11
- package/_types/core/TxEnvelope.d.ts.map +1 -0
- package/_types/core/{TransactionEnvelopeEip1559.d.ts → TxEnvelopeEip1559.d.ts} +54 -54
- package/_types/core/TxEnvelopeEip1559.d.ts.map +1 -0
- package/_types/core/{TransactionEnvelopeEip2930.d.ts → TxEnvelopeEip2930.d.ts} +55 -55
- package/_types/core/TxEnvelopeEip2930.d.ts.map +1 -0
- package/_types/core/{TransactionEnvelopeEip4844.d.ts → TxEnvelopeEip4844.d.ts} +54 -54
- package/_types/core/TxEnvelopeEip4844.d.ts.map +1 -0
- package/_types/core/{TransactionEnvelopeEip7702.d.ts → TxEnvelopeEip7702.d.ts} +49 -49
- package/_types/core/TxEnvelopeEip7702.d.ts.map +1 -0
- package/_types/core/{TransactionEnvelopeLegacy.d.ts → TxEnvelopeLegacy.d.ts} +54 -54
- package/_types/core/TxEnvelopeLegacy.d.ts.map +1 -0
- package/_types/core/WebAuthnP256.d.ts +1 -1
- package/_types/core/WebAuthnP256.d.ts.map +1 -1
- package/_types/erc8021/Attribution.d.ts +20 -6
- package/_types/erc8021/Attribution.d.ts.map +1 -1
- package/_types/index.d.ts +192 -192
- package/_types/index.d.ts.map +1 -1
- package/_types/index.docs.d.ts +1 -0
- package/_types/index.docs.d.ts.map +1 -1
- package/_types/tempo/AuthorizationTempo.d.ts +688 -0
- package/_types/tempo/AuthorizationTempo.d.ts.map +1 -0
- package/_types/tempo/KeyAuthorization.d.ts +437 -0
- package/_types/tempo/KeyAuthorization.d.ts.map +1 -0
- package/_types/tempo/PoolId.d.ts +33 -0
- package/_types/tempo/PoolId.d.ts.map +1 -0
- package/_types/tempo/SignatureEnvelope.d.ts +438 -0
- package/_types/tempo/SignatureEnvelope.d.ts.map +1 -0
- package/_types/tempo/Tick.d.ts +120 -0
- package/_types/tempo/Tick.d.ts.map +1 -0
- package/_types/tempo/TokenId.d.ts +55 -0
- package/_types/tempo/TokenId.d.ts.map +1 -0
- package/_types/tempo/TokenRole.d.ts +29 -0
- package/_types/tempo/TokenRole.d.ts.map +1 -0
- package/_types/tempo/Transaction.d.ts +208 -0
- package/_types/tempo/Transaction.d.ts.map +1 -0
- package/_types/tempo/TransactionReceipt.d.ts +165 -0
- package/_types/tempo/TransactionReceipt.d.ts.map +1 -0
- package/_types/tempo/TransactionRequest.d.ts +89 -0
- package/_types/tempo/TransactionRequest.d.ts.map +1 -0
- package/_types/tempo/TxEnvelopeTempo.d.ts +551 -0
- package/_types/tempo/TxEnvelopeTempo.d.ts.map +1 -0
- package/_types/tempo/index.d.ts +300 -0
- package/_types/tempo/index.d.ts.map +1 -0
- package/_types/version.d.ts +1 -1
- package/core/Blobs.ts +8 -8
- package/core/{TransactionEnvelope.ts → TxEnvelope.ts} +10 -10
- package/core/{TransactionEnvelopeEip1559.ts → TxEnvelopeEip1559.ts} +60 -69
- package/core/{TransactionEnvelopeEip2930.ts → TxEnvelopeEip2930.ts} +61 -72
- package/core/{TransactionEnvelopeEip4844.ts → TxEnvelopeEip4844.ts} +62 -71
- package/core/{TransactionEnvelopeEip7702.ts → TxEnvelopeEip7702.ts} +58 -67
- package/core/{TransactionEnvelopeLegacy.ts → TxEnvelopeLegacy.ts} +59 -68
- package/core/WebAuthnP256.ts +3 -1
- package/erc8021/Attribution.ts +77 -15
- package/index.docs.ts +1 -0
- package/index.ts +192 -195
- package/package.json +91 -31
- package/tempo/AuthorizationTempo/package.json +6 -0
- package/tempo/AuthorizationTempo.test.ts +1293 -0
- package/tempo/AuthorizationTempo.ts +884 -0
- package/tempo/KeyAuthorization/package.json +6 -0
- package/tempo/KeyAuthorization.test.ts +1373 -0
- package/tempo/KeyAuthorization.ts +622 -0
- package/tempo/PoolId/package.json +6 -0
- package/tempo/PoolId.test.ts +33 -0
- package/tempo/PoolId.ts +42 -0
- package/tempo/SignatureEnvelope/package.json +6 -0
- package/tempo/SignatureEnvelope.test.ts +1877 -0
- package/tempo/SignatureEnvelope.ts +973 -0
- package/tempo/Tick/package.json +6 -0
- package/tempo/Tick.test.ts +281 -0
- package/tempo/Tick.ts +186 -0
- package/tempo/TokenId/package.json +6 -0
- package/tempo/TokenId.test.ts +40 -0
- package/tempo/TokenId.ts +80 -0
- package/tempo/TokenRole/package.json +6 -0
- package/tempo/TokenRole.test.ts +16 -0
- package/tempo/TokenRole.ts +45 -0
- package/tempo/Transaction/package.json +6 -0
- package/tempo/Transaction.test.ts +523 -0
- package/tempo/Transaction.ts +339 -0
- package/tempo/TransactionReceipt/package.json +6 -0
- package/tempo/TransactionReceipt.ts +200 -0
- package/tempo/TransactionRequest/package.json +6 -0
- package/tempo/TransactionRequest.ts +160 -0
- package/tempo/TxEnvelopeTempo/package.json +6 -0
- package/tempo/TxEnvelopeTempo.test.ts +1371 -0
- package/tempo/TxEnvelopeTempo.ts +972 -0
- package/tempo/e2e.test.ts +1387 -0
- package/tempo/index.ts +308 -0
- package/tempo/package.json +6 -0
- package/version.ts +1 -1
- package/TransactionEnvelope/package.json +0 -6
- package/TransactionEnvelopeEip1559/package.json +0 -6
- package/TransactionEnvelopeEip2930/package.json +0 -6
- package/TransactionEnvelopeEip4844/package.json +0 -6
- package/TransactionEnvelopeEip7702/package.json +0 -6
- package/TransactionEnvelopeLegacy/package.json +0 -6
- package/_cjs/core/TransactionEnvelope.js.map +0 -1
- package/_cjs/core/TransactionEnvelopeEip1559.js.map +0 -1
- package/_cjs/core/TransactionEnvelopeEip2930.js.map +0 -1
- package/_cjs/core/TransactionEnvelopeEip4844.js.map +0 -1
- package/_cjs/core/TransactionEnvelopeEip7702.js.map +0 -1
- package/_cjs/core/TransactionEnvelopeLegacy.js.map +0 -1
- package/_esm/core/TransactionEnvelope.js.map +0 -1
- package/_esm/core/TransactionEnvelopeEip1559.js.map +0 -1
- package/_esm/core/TransactionEnvelopeEip2930.js.map +0 -1
- package/_esm/core/TransactionEnvelopeEip4844.js.map +0 -1
- package/_esm/core/TransactionEnvelopeEip7702.js.map +0 -1
- package/_esm/core/TransactionEnvelopeLegacy.js.map +0 -1
- package/_types/core/TransactionEnvelope.d.ts.map +0 -1
- package/_types/core/TransactionEnvelopeEip1559.d.ts.map +0 -1
- package/_types/core/TransactionEnvelopeEip2930.d.ts.map +0 -1
- package/_types/core/TransactionEnvelopeEip4844.d.ts.map +0 -1
- package/_types/core/TransactionEnvelopeEip7702.d.ts.map +0 -1
- package/_types/core/TransactionEnvelopeLegacy.d.ts.map +0 -1
|
@@ -0,0 +1,660 @@
|
|
|
1
|
+
import * as Errors from '../core/Errors.js';
|
|
2
|
+
import * as Hex from '../core/Hex.js';
|
|
3
|
+
import * as Json from '../core/Json.js';
|
|
4
|
+
import * as Signature from '../core/Signature.js';
|
|
5
|
+
/** Signature type identifiers for encoding/decoding */
|
|
6
|
+
const serializedP256Type = '0x01';
|
|
7
|
+
const serializedWebAuthnType = '0x02';
|
|
8
|
+
const serializedKeychainType = '0x03';
|
|
9
|
+
/** List of supported signature types. */
|
|
10
|
+
export const types = ['secp256k1', 'p256', 'webAuthn'];
|
|
11
|
+
/**
|
|
12
|
+
* Asserts that a {@link ox#SignatureEnvelope.SignatureEnvelope} is valid.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```ts twoslash
|
|
16
|
+
* import { SignatureEnvelope } from 'ox/tempo'
|
|
17
|
+
*
|
|
18
|
+
* SignatureEnvelope.assert({
|
|
19
|
+
* type: 'secp256k1',
|
|
20
|
+
* signature: {
|
|
21
|
+
* r: 0n,
|
|
22
|
+
* s: 0n,
|
|
23
|
+
* yParity: 0,
|
|
24
|
+
* },
|
|
25
|
+
* })
|
|
26
|
+
* ```
|
|
27
|
+
*
|
|
28
|
+
* @param envelope - The signature envelope to assert.
|
|
29
|
+
* @throws `CoercionError` if the envelope type cannot be determined.
|
|
30
|
+
*/
|
|
31
|
+
export function assert(envelope) {
|
|
32
|
+
const type = getType(envelope);
|
|
33
|
+
if (type === 'secp256k1') {
|
|
34
|
+
const secp256k1 = envelope;
|
|
35
|
+
Signature.assert(secp256k1.signature);
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
if (type === 'p256') {
|
|
39
|
+
const p256 = envelope;
|
|
40
|
+
const missing = [];
|
|
41
|
+
if (typeof p256.signature?.r !== 'bigint')
|
|
42
|
+
missing.push('signature.r');
|
|
43
|
+
if (typeof p256.signature?.s !== 'bigint')
|
|
44
|
+
missing.push('signature.s');
|
|
45
|
+
if (typeof p256.prehash !== 'boolean')
|
|
46
|
+
missing.push('prehash');
|
|
47
|
+
if (!p256.publicKey)
|
|
48
|
+
missing.push('publicKey');
|
|
49
|
+
else {
|
|
50
|
+
if (typeof p256.publicKey.x !== 'bigint')
|
|
51
|
+
missing.push('publicKey.x');
|
|
52
|
+
if (typeof p256.publicKey.y !== 'bigint')
|
|
53
|
+
missing.push('publicKey.y');
|
|
54
|
+
}
|
|
55
|
+
if (missing.length > 0)
|
|
56
|
+
throw new MissingPropertiesError({ envelope, missing, type: 'p256' });
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
if (type === 'webAuthn') {
|
|
60
|
+
const webauthn = envelope;
|
|
61
|
+
const missing = [];
|
|
62
|
+
if (typeof webauthn.signature?.r !== 'bigint')
|
|
63
|
+
missing.push('signature.r');
|
|
64
|
+
if (typeof webauthn.signature?.s !== 'bigint')
|
|
65
|
+
missing.push('signature.s');
|
|
66
|
+
if (!webauthn.metadata)
|
|
67
|
+
missing.push('metadata');
|
|
68
|
+
else {
|
|
69
|
+
if (!webauthn.metadata.authenticatorData)
|
|
70
|
+
missing.push('metadata.authenticatorData');
|
|
71
|
+
if (!webauthn.metadata.clientDataJSON)
|
|
72
|
+
missing.push('metadata.clientDataJSON');
|
|
73
|
+
}
|
|
74
|
+
if (!webauthn.publicKey)
|
|
75
|
+
missing.push('publicKey');
|
|
76
|
+
else {
|
|
77
|
+
if (typeof webauthn.publicKey.x !== 'bigint')
|
|
78
|
+
missing.push('publicKey.x');
|
|
79
|
+
if (typeof webauthn.publicKey.y !== 'bigint')
|
|
80
|
+
missing.push('publicKey.y');
|
|
81
|
+
}
|
|
82
|
+
if (missing.length > 0)
|
|
83
|
+
throw new MissingPropertiesError({ envelope, missing, type: 'webAuthn' });
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
if (type === 'keychain') {
|
|
87
|
+
const keychain = envelope;
|
|
88
|
+
assert(keychain.inner);
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Deserializes a hex-encoded signature envelope into a typed signature object.
|
|
94
|
+
*
|
|
95
|
+
* Wire format detection:
|
|
96
|
+
* - 65 bytes (no prefix): secp256k1 signature
|
|
97
|
+
* - Type `0x01` + 129 bytes: P256 signature (r, s, pubKeyX, pubKeyY, prehash)
|
|
98
|
+
* - Type `0x02` + variable: WebAuthn signature (webauthnData, r, s, pubKeyX, pubKeyY)
|
|
99
|
+
* - Type `0x03` + 20 bytes + inner: Keychain signature (userAddress + inner signature)
|
|
100
|
+
*
|
|
101
|
+
* [Signature Types](https://docs.tempo.xyz/protocol/transactions/spec-tempo-transaction#signature-types)
|
|
102
|
+
*
|
|
103
|
+
* @example
|
|
104
|
+
* ```ts twoslash
|
|
105
|
+
* import { SignatureEnvelope } from 'ox/tempo'
|
|
106
|
+
*
|
|
107
|
+
* const envelope = SignatureEnvelope.deserialize('0x...')
|
|
108
|
+
* ```
|
|
109
|
+
*
|
|
110
|
+
* @param serialized - The hex-encoded signature envelope to deserialize.
|
|
111
|
+
* @returns The deserialized signature envelope.
|
|
112
|
+
* @throws `CoercionError` if the serialized value cannot be coerced to a valid signature envelope.
|
|
113
|
+
*/
|
|
114
|
+
export function deserialize(serialized) {
|
|
115
|
+
const size = Hex.size(serialized);
|
|
116
|
+
// Backward compatibility: 65 bytes means secp256k1 without type identifier
|
|
117
|
+
if (size === 65) {
|
|
118
|
+
const signature = Signature.fromHex(serialized);
|
|
119
|
+
Signature.assert(signature);
|
|
120
|
+
return { signature, type: 'secp256k1' };
|
|
121
|
+
}
|
|
122
|
+
// For all other lengths, first byte is the type identifier
|
|
123
|
+
const typeId = Hex.slice(serialized, 0, 1);
|
|
124
|
+
const data = Hex.slice(serialized, 1);
|
|
125
|
+
const dataSize = Hex.size(data);
|
|
126
|
+
if (typeId === serializedP256Type) {
|
|
127
|
+
// P256: 32 (r) + 32 (s) + 32 (pubKeyX) + 32 (pubKeyY) + 1 (prehash) = 129 bytes
|
|
128
|
+
if (dataSize !== 129)
|
|
129
|
+
throw new InvalidSerializedError({
|
|
130
|
+
reason: `Invalid P256 signature envelope size: expected 129 bytes, got ${dataSize} bytes`,
|
|
131
|
+
serialized,
|
|
132
|
+
});
|
|
133
|
+
return {
|
|
134
|
+
publicKey: {
|
|
135
|
+
prefix: 4,
|
|
136
|
+
x: Hex.toBigInt(Hex.slice(data, 64, 96)),
|
|
137
|
+
y: Hex.toBigInt(Hex.slice(data, 96, 128)),
|
|
138
|
+
},
|
|
139
|
+
prehash: Hex.toNumber(Hex.slice(data, 128, 129)) !== 0,
|
|
140
|
+
signature: {
|
|
141
|
+
r: Hex.toBigInt(Hex.slice(data, 0, 32)),
|
|
142
|
+
s: Hex.toBigInt(Hex.slice(data, 32, 64)),
|
|
143
|
+
},
|
|
144
|
+
type: 'p256',
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
if (typeId === serializedWebAuthnType) {
|
|
148
|
+
// WebAuthn: variable (webauthnData) + 32 (r) + 32 (s) + 32 (pubKeyX) + 32 (pubKeyY)
|
|
149
|
+
// Minimum: 128 bytes (at least some authenticator data + signature components)
|
|
150
|
+
if (dataSize < 128)
|
|
151
|
+
throw new InvalidSerializedError({
|
|
152
|
+
reason: `Invalid WebAuthn signature envelope size: expected at least 128 bytes, got ${dataSize} bytes`,
|
|
153
|
+
serialized,
|
|
154
|
+
});
|
|
155
|
+
const webauthnDataSize = dataSize - 128;
|
|
156
|
+
const webauthnData = Hex.slice(data, 0, webauthnDataSize);
|
|
157
|
+
// Parse webauthnData into authenticatorData and clientDataJSON
|
|
158
|
+
// According to the Rust code, it's authenticatorData || clientDataJSON
|
|
159
|
+
// We need to find the split point (minimum authenticatorData is 37 bytes)
|
|
160
|
+
let authenticatorData;
|
|
161
|
+
let clientDataJSON;
|
|
162
|
+
// Try to find the JSON start (clientDataJSON should start with '{')
|
|
163
|
+
for (let split = 37; split < webauthnDataSize; split++) {
|
|
164
|
+
const potentialJson = Hex.toString(Hex.slice(webauthnData, split));
|
|
165
|
+
if (potentialJson.startsWith('{') && potentialJson.endsWith('}')) {
|
|
166
|
+
try {
|
|
167
|
+
JSON.parse(potentialJson);
|
|
168
|
+
authenticatorData = Hex.slice(webauthnData, 0, split);
|
|
169
|
+
clientDataJSON = potentialJson;
|
|
170
|
+
break;
|
|
171
|
+
}
|
|
172
|
+
catch { }
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
if (!authenticatorData || !clientDataJSON)
|
|
176
|
+
throw new InvalidSerializedError({
|
|
177
|
+
reason: 'Unable to parse WebAuthn metadata: could not extract valid authenticatorData and clientDataJSON',
|
|
178
|
+
serialized,
|
|
179
|
+
});
|
|
180
|
+
return {
|
|
181
|
+
publicKey: {
|
|
182
|
+
prefix: 4,
|
|
183
|
+
x: Hex.toBigInt(Hex.slice(data, webauthnDataSize + 64, webauthnDataSize + 96)),
|
|
184
|
+
y: Hex.toBigInt(Hex.slice(data, webauthnDataSize + 96, webauthnDataSize + 128)),
|
|
185
|
+
},
|
|
186
|
+
metadata: {
|
|
187
|
+
authenticatorData,
|
|
188
|
+
clientDataJSON,
|
|
189
|
+
},
|
|
190
|
+
signature: {
|
|
191
|
+
r: Hex.toBigInt(Hex.slice(data, webauthnDataSize, webauthnDataSize + 32)),
|
|
192
|
+
s: Hex.toBigInt(Hex.slice(data, webauthnDataSize + 32, webauthnDataSize + 64)),
|
|
193
|
+
},
|
|
194
|
+
type: 'webAuthn',
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
if (typeId === serializedKeychainType) {
|
|
198
|
+
const userAddress = Hex.slice(data, 0, 20);
|
|
199
|
+
const inner = deserialize(Hex.slice(data, 20));
|
|
200
|
+
return {
|
|
201
|
+
userAddress,
|
|
202
|
+
inner,
|
|
203
|
+
type: 'keychain',
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
throw new InvalidSerializedError({
|
|
207
|
+
reason: `Unknown signature type identifier: ${typeId}. Expected ${serializedP256Type} (P256) or ${serializedWebAuthnType} (WebAuthn)`,
|
|
208
|
+
serialized,
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* Coerces a value to a signature envelope.
|
|
213
|
+
*
|
|
214
|
+
* Accepts either a serialized hex string or an existing signature envelope object.
|
|
215
|
+
* Use this to wrap raw signatures from {@link ox#Secp256k1.(sign:function)}, {@link ox#P256.(sign:function)},
|
|
216
|
+
* {@link ox#WebCryptoP256.(sign:function)}, or {@link ox#WebAuthnP256.(sign:function)} into the envelope format
|
|
217
|
+
* required by Tempo transactions.
|
|
218
|
+
*
|
|
219
|
+
* [Signature Types](https://docs.tempo.xyz/protocol/transactions/spec-tempo-transaction#signature-types)
|
|
220
|
+
*
|
|
221
|
+
* @example
|
|
222
|
+
* ### Secp256k1
|
|
223
|
+
*
|
|
224
|
+
* Standard Ethereum ECDSA signature using the secp256k1 curve.
|
|
225
|
+
*
|
|
226
|
+
* ```ts twoslash
|
|
227
|
+
* import { Secp256k1 } from 'ox'
|
|
228
|
+
* import { SignatureEnvelope } from 'ox/tempo'
|
|
229
|
+
*
|
|
230
|
+
* const privateKey = Secp256k1.randomPrivateKey()
|
|
231
|
+
* const signature = Secp256k1.sign({ payload: '0xdeadbeef', privateKey })
|
|
232
|
+
*
|
|
233
|
+
* const envelope = SignatureEnvelope.from(signature)
|
|
234
|
+
* ```
|
|
235
|
+
*
|
|
236
|
+
* @example
|
|
237
|
+
* ### P256
|
|
238
|
+
*
|
|
239
|
+
* ECDSA signature using the P-256 (secp256r1) curve. Requires embedding the
|
|
240
|
+
* public key.
|
|
241
|
+
*
|
|
242
|
+
* ```ts twoslash
|
|
243
|
+
* import { P256 } from 'ox'
|
|
244
|
+
* import { SignatureEnvelope } from 'ox/tempo'
|
|
245
|
+
*
|
|
246
|
+
* const { privateKey, publicKey } = P256.createKeyPair()
|
|
247
|
+
* const signature = P256.sign({ payload: '0xdeadbeef', privateKey })
|
|
248
|
+
*
|
|
249
|
+
* const envelope = SignatureEnvelope.from({
|
|
250
|
+
* signature,
|
|
251
|
+
* publicKey,
|
|
252
|
+
* })
|
|
253
|
+
* ```
|
|
254
|
+
*
|
|
255
|
+
* @example
|
|
256
|
+
* ### P256 (WebCrypto)
|
|
257
|
+
*
|
|
258
|
+
* When using WebCrypto keys, `prehash` must be `true` since WebCrypto always
|
|
259
|
+
* SHA256 hashes the digest before signing.
|
|
260
|
+
*
|
|
261
|
+
* ```ts twoslash
|
|
262
|
+
* // @noErrors
|
|
263
|
+
* import { WebCryptoP256 } from 'ox'
|
|
264
|
+
* import { SignatureEnvelope } from 'ox/tempo'
|
|
265
|
+
*
|
|
266
|
+
* const { privateKey, publicKey } = await WebCryptoP256.createKeyPair()
|
|
267
|
+
* const signature = await WebCryptoP256.sign({ payload: '0xdeadbeef', privateKey })
|
|
268
|
+
*
|
|
269
|
+
* const envelope = SignatureEnvelope.from({
|
|
270
|
+
* signature,
|
|
271
|
+
* publicKey,
|
|
272
|
+
* prehash: true,
|
|
273
|
+
* })
|
|
274
|
+
* ```
|
|
275
|
+
*
|
|
276
|
+
* @example
|
|
277
|
+
* ### WebAuthn
|
|
278
|
+
*
|
|
279
|
+
* Passkey-based signature using WebAuthn. Includes authenticator metadata
|
|
280
|
+
* (authenticatorData and clientDataJSON) along with the P-256 signature and
|
|
281
|
+
* public key.
|
|
282
|
+
*
|
|
283
|
+
* ```ts twoslash
|
|
284
|
+
* // @noErrors
|
|
285
|
+
* import { WebAuthnP256 } from 'ox'
|
|
286
|
+
* import { SignatureEnvelope } from 'ox/tempo'
|
|
287
|
+
*
|
|
288
|
+
* const credential = await WebAuthnP256.createCredential({
|
|
289
|
+
* name: 'Example',
|
|
290
|
+
* })
|
|
291
|
+
*
|
|
292
|
+
* const { metadata, signature } = await WebAuthnP256.sign({
|
|
293
|
+
* challenge: '0xdeadbeef',
|
|
294
|
+
* credentialId: credential.id,
|
|
295
|
+
* })
|
|
296
|
+
*
|
|
297
|
+
* const envelope = SignatureEnvelope.from({
|
|
298
|
+
* signature,
|
|
299
|
+
* publicKey: credential.publicKey,
|
|
300
|
+
* metadata,
|
|
301
|
+
* })
|
|
302
|
+
* ```
|
|
303
|
+
*
|
|
304
|
+
* @example
|
|
305
|
+
* ### Keychain
|
|
306
|
+
*
|
|
307
|
+
* Wraps another signature type with a user address, used for delegated signing
|
|
308
|
+
* via access keys on behalf of a root account.
|
|
309
|
+
*
|
|
310
|
+
* ```ts twoslash
|
|
311
|
+
* import { Secp256k1 } from 'ox'
|
|
312
|
+
* import { SignatureEnvelope } from 'ox/tempo'
|
|
313
|
+
*
|
|
314
|
+
* const privateKey = Secp256k1.randomPrivateKey()
|
|
315
|
+
* const signature = Secp256k1.sign({ payload: '0xdeadbeef', privateKey })
|
|
316
|
+
*
|
|
317
|
+
* const envelope = SignatureEnvelope.from({
|
|
318
|
+
* userAddress: '0x1234567890123456789012345678901234567890',
|
|
319
|
+
* inner: SignatureEnvelope.from(signature),
|
|
320
|
+
* })
|
|
321
|
+
* ```
|
|
322
|
+
*
|
|
323
|
+
* @param value - The value to coerce (either a hex string or signature envelope).
|
|
324
|
+
* @returns The signature envelope.
|
|
325
|
+
*/
|
|
326
|
+
export function from(value) {
|
|
327
|
+
if (typeof value === 'string')
|
|
328
|
+
return deserialize(value);
|
|
329
|
+
if (typeof value === 'object' &&
|
|
330
|
+
value !== null &&
|
|
331
|
+
'r' in value &&
|
|
332
|
+
's' in value &&
|
|
333
|
+
'yParity' in value)
|
|
334
|
+
return { signature: value, type: 'secp256k1' };
|
|
335
|
+
const type = getType(value);
|
|
336
|
+
return {
|
|
337
|
+
...value,
|
|
338
|
+
...(type === 'p256' ? { prehash: value.prehash } : {}),
|
|
339
|
+
type,
|
|
340
|
+
};
|
|
341
|
+
}
|
|
342
|
+
/**
|
|
343
|
+
* Converts an RPC-formatted signature envelope to a typed signature envelope.
|
|
344
|
+
*
|
|
345
|
+
* @example
|
|
346
|
+
* ```ts twoslash
|
|
347
|
+
* import { SignatureEnvelope } from 'ox/tempo'
|
|
348
|
+
*
|
|
349
|
+
* const envelope = SignatureEnvelope.fromRpc({
|
|
350
|
+
* r: '0x0',
|
|
351
|
+
* s: '0x0',
|
|
352
|
+
* yParity: '0x0',
|
|
353
|
+
* type: 'secp256k1',
|
|
354
|
+
* })
|
|
355
|
+
* ```
|
|
356
|
+
*
|
|
357
|
+
* @param envelope - The RPC signature envelope to convert.
|
|
358
|
+
* @returns The signature envelope with bigint values.
|
|
359
|
+
*/
|
|
360
|
+
export function fromRpc(envelope) {
|
|
361
|
+
if (envelope.type === 'secp256k1')
|
|
362
|
+
return {
|
|
363
|
+
signature: Signature.fromRpc(envelope),
|
|
364
|
+
type: 'secp256k1',
|
|
365
|
+
};
|
|
366
|
+
if (envelope.type === 'p256') {
|
|
367
|
+
return {
|
|
368
|
+
prehash: envelope.prehash,
|
|
369
|
+
publicKey: {
|
|
370
|
+
prefix: 4,
|
|
371
|
+
x: Hex.toBigInt(envelope.pubKeyX),
|
|
372
|
+
y: Hex.toBigInt(envelope.pubKeyY),
|
|
373
|
+
},
|
|
374
|
+
signature: {
|
|
375
|
+
r: Hex.toBigInt(envelope.r),
|
|
376
|
+
s: Hex.toBigInt(envelope.s),
|
|
377
|
+
},
|
|
378
|
+
type: 'p256',
|
|
379
|
+
};
|
|
380
|
+
}
|
|
381
|
+
if (envelope.type === 'webAuthn') {
|
|
382
|
+
const webauthnData = envelope.webauthnData;
|
|
383
|
+
const webauthnDataSize = Hex.size(webauthnData);
|
|
384
|
+
// Parse webauthnData into authenticatorData and clientDataJSON
|
|
385
|
+
let authenticatorData;
|
|
386
|
+
let clientDataJSON;
|
|
387
|
+
// Try to find the JSON start (clientDataJSON should start with '{')
|
|
388
|
+
for (let split = 37; split < webauthnDataSize; split++) {
|
|
389
|
+
const potentialJson = Hex.toString(Hex.slice(webauthnData, split));
|
|
390
|
+
if (potentialJson.startsWith('{') && potentialJson.endsWith('}')) {
|
|
391
|
+
try {
|
|
392
|
+
JSON.parse(potentialJson);
|
|
393
|
+
authenticatorData = Hex.slice(webauthnData, 0, split);
|
|
394
|
+
clientDataJSON = potentialJson;
|
|
395
|
+
break;
|
|
396
|
+
}
|
|
397
|
+
catch { }
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
if (!authenticatorData || !clientDataJSON)
|
|
401
|
+
throw new InvalidSerializedError({
|
|
402
|
+
reason: 'Unable to parse WebAuthn metadata: could not extract valid authenticatorData and clientDataJSON',
|
|
403
|
+
serialized: webauthnData,
|
|
404
|
+
});
|
|
405
|
+
return {
|
|
406
|
+
metadata: {
|
|
407
|
+
authenticatorData,
|
|
408
|
+
clientDataJSON,
|
|
409
|
+
},
|
|
410
|
+
publicKey: {
|
|
411
|
+
prefix: 4,
|
|
412
|
+
x: Hex.toBigInt(envelope.pubKeyX),
|
|
413
|
+
y: Hex.toBigInt(envelope.pubKeyY),
|
|
414
|
+
},
|
|
415
|
+
signature: {
|
|
416
|
+
r: Hex.toBigInt(envelope.r),
|
|
417
|
+
s: Hex.toBigInt(envelope.s),
|
|
418
|
+
},
|
|
419
|
+
type: 'webAuthn',
|
|
420
|
+
};
|
|
421
|
+
}
|
|
422
|
+
if (envelope.type === 'keychain' ||
|
|
423
|
+
('userAddress' in envelope && 'signature' in envelope))
|
|
424
|
+
return {
|
|
425
|
+
type: 'keychain',
|
|
426
|
+
userAddress: envelope.userAddress,
|
|
427
|
+
inner: fromRpc(envelope.signature),
|
|
428
|
+
};
|
|
429
|
+
throw new CoercionError({ envelope });
|
|
430
|
+
}
|
|
431
|
+
/**
|
|
432
|
+
* Determines the signature type of an envelope.
|
|
433
|
+
*
|
|
434
|
+
* @example
|
|
435
|
+
* ```ts twoslash
|
|
436
|
+
* import { SignatureEnvelope } from 'ox/tempo'
|
|
437
|
+
*
|
|
438
|
+
* const type = SignatureEnvelope.getType({
|
|
439
|
+
* signature: { r: 0n, s: 0n, yParity: 0 },
|
|
440
|
+
* })
|
|
441
|
+
* // @log: 'secp256k1'
|
|
442
|
+
* ```
|
|
443
|
+
*
|
|
444
|
+
* @param envelope - The signature envelope to inspect.
|
|
445
|
+
* @returns The signature type ('secp256k1', 'p256', or 'webAuthn').
|
|
446
|
+
* @throws `CoercionError` if the envelope type cannot be determined.
|
|
447
|
+
*/
|
|
448
|
+
export function getType(envelope) {
|
|
449
|
+
if (typeof envelope !== 'object' || envelope === null)
|
|
450
|
+
throw new CoercionError({ envelope });
|
|
451
|
+
if ('type' in envelope && envelope.type)
|
|
452
|
+
return envelope.type;
|
|
453
|
+
// Detect secp256k1 signature (backwards compatibility: also support flat structure)
|
|
454
|
+
if ('signature' in envelope &&
|
|
455
|
+
!('publicKey' in envelope) &&
|
|
456
|
+
typeof envelope.signature === 'object' &&
|
|
457
|
+
envelope.signature !== null &&
|
|
458
|
+
'r' in envelope.signature &&
|
|
459
|
+
's' in envelope.signature &&
|
|
460
|
+
'yParity' in envelope.signature)
|
|
461
|
+
return 'secp256k1';
|
|
462
|
+
// Detect secp256k1 signature (flat structure)
|
|
463
|
+
if ('r' in envelope && 's' in envelope && 'yParity' in envelope)
|
|
464
|
+
return 'secp256k1';
|
|
465
|
+
// Detect P256 signature
|
|
466
|
+
if ('signature' in envelope &&
|
|
467
|
+
'prehash' in envelope &&
|
|
468
|
+
'publicKey' in envelope &&
|
|
469
|
+
typeof envelope.prehash === 'boolean')
|
|
470
|
+
return 'p256';
|
|
471
|
+
// Detect WebAuthn signature
|
|
472
|
+
if ('signature' in envelope &&
|
|
473
|
+
'metadata' in envelope &&
|
|
474
|
+
'publicKey' in envelope)
|
|
475
|
+
return 'webAuthn';
|
|
476
|
+
// Detect Keychain signature
|
|
477
|
+
if ('userAddress' in envelope && 'inner' in envelope)
|
|
478
|
+
return 'keychain';
|
|
479
|
+
throw new CoercionError({
|
|
480
|
+
envelope,
|
|
481
|
+
});
|
|
482
|
+
}
|
|
483
|
+
/**
|
|
484
|
+
* Serializes a signature envelope to a hex-encoded string.
|
|
485
|
+
*
|
|
486
|
+
* Wire format:
|
|
487
|
+
* - secp256k1: 65 bytes (no type prefix, for backward compatibility)
|
|
488
|
+
* - P256: `0x01` + r (32) + s (32) + pubKeyX (32) + pubKeyY (32) + prehash (1) = 130 bytes
|
|
489
|
+
* - WebAuthn: `0x02` + webauthnData (variable) + r (32) + s (32) + pubKeyX (32) + pubKeyY (32)
|
|
490
|
+
* - Keychain: `0x03` + userAddress (20) + inner signature (recursive)
|
|
491
|
+
*
|
|
492
|
+
* [Signature Types](https://docs.tempo.xyz/protocol/transactions/spec-tempo-transaction#signature-types)
|
|
493
|
+
*
|
|
494
|
+
* @example
|
|
495
|
+
* ```ts twoslash
|
|
496
|
+
* import { SignatureEnvelope } from 'ox/tempo'
|
|
497
|
+
*
|
|
498
|
+
* const serialized = SignatureEnvelope.serialize({
|
|
499
|
+
* signature: { r: 0n, s: 0n, yParity: 0 },
|
|
500
|
+
* type: 'secp256k1',
|
|
501
|
+
* })
|
|
502
|
+
* ```
|
|
503
|
+
*
|
|
504
|
+
* @param envelope - The signature envelope to serialize.
|
|
505
|
+
* @returns The hex-encoded serialized signature.
|
|
506
|
+
* @throws `CoercionError` if the envelope cannot be serialized.
|
|
507
|
+
*/
|
|
508
|
+
export function serialize(envelope) {
|
|
509
|
+
const type = getType(envelope);
|
|
510
|
+
// Backward compatibility: no type identifier for secp256k1
|
|
511
|
+
if (type === 'secp256k1') {
|
|
512
|
+
const secp256k1 = envelope;
|
|
513
|
+
return Signature.toHex(secp256k1.signature);
|
|
514
|
+
}
|
|
515
|
+
if (type === 'p256') {
|
|
516
|
+
const p256 = envelope;
|
|
517
|
+
// Format: 1 byte (type) + 32 (r) + 32 (s) + 32 (pubKeyX) + 32 (pubKeyY) + 1 (prehash)
|
|
518
|
+
return Hex.concat(serializedP256Type, Hex.fromNumber(p256.signature.r, { size: 32 }), Hex.fromNumber(p256.signature.s, { size: 32 }), Hex.fromNumber(p256.publicKey.x, { size: 32 }), Hex.fromNumber(p256.publicKey.y, { size: 32 }), Hex.fromNumber(p256.prehash ? 1 : 0, { size: 1 }));
|
|
519
|
+
}
|
|
520
|
+
if (type === 'webAuthn') {
|
|
521
|
+
const webauthn = envelope;
|
|
522
|
+
// Format: 1 byte (type) + variable (authenticatorData || clientDataJSON) + 32 (r) + 32 (s) + 32 (pubKeyX) + 32 (pubKeyY)
|
|
523
|
+
const webauthnData = Hex.concat(webauthn.metadata.authenticatorData, Hex.fromString(webauthn.metadata.clientDataJSON));
|
|
524
|
+
return Hex.concat(serializedWebAuthnType, webauthnData, Hex.fromNumber(webauthn.signature.r, { size: 32 }), Hex.fromNumber(webauthn.signature.s, { size: 32 }), Hex.fromNumber(webauthn.publicKey.x, { size: 32 }), Hex.fromNumber(webauthn.publicKey.y, { size: 32 }));
|
|
525
|
+
}
|
|
526
|
+
if (type === 'keychain') {
|
|
527
|
+
const keychain = envelope;
|
|
528
|
+
return Hex.concat(serializedKeychainType, keychain.userAddress, serialize(keychain.inner));
|
|
529
|
+
}
|
|
530
|
+
throw new CoercionError({ envelope });
|
|
531
|
+
}
|
|
532
|
+
/**
|
|
533
|
+
* Converts a signature envelope to RPC format.
|
|
534
|
+
*
|
|
535
|
+
* @example
|
|
536
|
+
* ```ts twoslash
|
|
537
|
+
* import { SignatureEnvelope } from 'ox/tempo'
|
|
538
|
+
*
|
|
539
|
+
* const rpc = SignatureEnvelope.toRpc({
|
|
540
|
+
* signature: { r: 0n, s: 0n, yParity: 0 },
|
|
541
|
+
* type: 'secp256k1',
|
|
542
|
+
* })
|
|
543
|
+
* ```
|
|
544
|
+
*
|
|
545
|
+
* @param envelope - The signature envelope to convert.
|
|
546
|
+
* @returns The RPC signature envelope with hex values.
|
|
547
|
+
*/
|
|
548
|
+
export function toRpc(envelope) {
|
|
549
|
+
const type = getType(envelope);
|
|
550
|
+
if (type === 'secp256k1') {
|
|
551
|
+
const secp256k1 = envelope;
|
|
552
|
+
return {
|
|
553
|
+
...Signature.toRpc(secp256k1.signature),
|
|
554
|
+
type: 'secp256k1',
|
|
555
|
+
};
|
|
556
|
+
}
|
|
557
|
+
if (type === 'p256') {
|
|
558
|
+
const p256 = envelope;
|
|
559
|
+
return {
|
|
560
|
+
prehash: p256.prehash,
|
|
561
|
+
pubKeyX: Hex.fromNumber(p256.publicKey.x, { size: 32 }),
|
|
562
|
+
pubKeyY: Hex.fromNumber(p256.publicKey.y, { size: 32 }),
|
|
563
|
+
r: Hex.fromNumber(p256.signature.r, { size: 32 }),
|
|
564
|
+
s: Hex.fromNumber(p256.signature.s, { size: 32 }),
|
|
565
|
+
type: 'p256',
|
|
566
|
+
};
|
|
567
|
+
}
|
|
568
|
+
if (type === 'webAuthn') {
|
|
569
|
+
const webauthn = envelope;
|
|
570
|
+
const webauthnData = Hex.concat(webauthn.metadata.authenticatorData, Hex.fromString(webauthn.metadata.clientDataJSON));
|
|
571
|
+
return {
|
|
572
|
+
pubKeyX: Hex.fromNumber(webauthn.publicKey.x, { size: 32 }),
|
|
573
|
+
pubKeyY: Hex.fromNumber(webauthn.publicKey.y, { size: 32 }),
|
|
574
|
+
r: Hex.fromNumber(webauthn.signature.r, { size: 32 }),
|
|
575
|
+
s: Hex.fromNumber(webauthn.signature.s, { size: 32 }),
|
|
576
|
+
type: 'webAuthn',
|
|
577
|
+
webauthnData,
|
|
578
|
+
};
|
|
579
|
+
}
|
|
580
|
+
if (type === 'keychain') {
|
|
581
|
+
const keychain = envelope;
|
|
582
|
+
return {
|
|
583
|
+
type: 'keychain',
|
|
584
|
+
userAddress: keychain.userAddress,
|
|
585
|
+
signature: toRpc(keychain.inner),
|
|
586
|
+
};
|
|
587
|
+
}
|
|
588
|
+
throw new CoercionError({ envelope });
|
|
589
|
+
}
|
|
590
|
+
/**
|
|
591
|
+
* Validates a signature envelope. Returns `true` if the envelope is valid, `false` otherwise.
|
|
592
|
+
*
|
|
593
|
+
* @example
|
|
594
|
+
* ```ts twoslash
|
|
595
|
+
* import { SignatureEnvelope } from 'ox/tempo'
|
|
596
|
+
*
|
|
597
|
+
* const valid = SignatureEnvelope.validate({
|
|
598
|
+
* signature: { r: 0n, s: 0n, yParity: 0 },
|
|
599
|
+
* type: 'secp256k1',
|
|
600
|
+
* })
|
|
601
|
+
* // @log: true
|
|
602
|
+
* ```
|
|
603
|
+
*
|
|
604
|
+
* @param envelope - The signature envelope to validate.
|
|
605
|
+
* @returns `true` if valid, `false` otherwise.
|
|
606
|
+
*/
|
|
607
|
+
export function validate(envelope) {
|
|
608
|
+
try {
|
|
609
|
+
assert(envelope);
|
|
610
|
+
return true;
|
|
611
|
+
}
|
|
612
|
+
catch {
|
|
613
|
+
return false;
|
|
614
|
+
}
|
|
615
|
+
}
|
|
616
|
+
/**
|
|
617
|
+
* Error thrown when a signature envelope cannot be coerced to a valid type.
|
|
618
|
+
*/
|
|
619
|
+
export class CoercionError extends Errors.BaseError {
|
|
620
|
+
constructor({ envelope }) {
|
|
621
|
+
super(`Unable to coerce value (\`${Json.stringify(envelope)}\`) to a valid signature envelope.`);
|
|
622
|
+
Object.defineProperty(this, "name", {
|
|
623
|
+
enumerable: true,
|
|
624
|
+
configurable: true,
|
|
625
|
+
writable: true,
|
|
626
|
+
value: 'SignatureEnvelope.CoercionError'
|
|
627
|
+
});
|
|
628
|
+
}
|
|
629
|
+
}
|
|
630
|
+
/**
|
|
631
|
+
* Error thrown when a signature envelope is missing required properties.
|
|
632
|
+
*/
|
|
633
|
+
export class MissingPropertiesError extends Errors.BaseError {
|
|
634
|
+
constructor({ envelope, missing, type, }) {
|
|
635
|
+
super(`Signature envelope of type "${type}" is missing required properties: ${missing.map((m) => `\`${m}\``).join(', ')}.\n\nProvided: ${Json.stringify(envelope)}`);
|
|
636
|
+
Object.defineProperty(this, "name", {
|
|
637
|
+
enumerable: true,
|
|
638
|
+
configurable: true,
|
|
639
|
+
writable: true,
|
|
640
|
+
value: 'SignatureEnvelope.MissingPropertiesError'
|
|
641
|
+
});
|
|
642
|
+
}
|
|
643
|
+
}
|
|
644
|
+
/**
|
|
645
|
+
* Error thrown when a serialized signature envelope cannot be deserialized.
|
|
646
|
+
*/
|
|
647
|
+
export class InvalidSerializedError extends Errors.BaseError {
|
|
648
|
+
constructor({ reason, serialized, }) {
|
|
649
|
+
super(`Unable to deserialize signature envelope: ${reason}`, {
|
|
650
|
+
metaMessages: [`Serialized: ${serialized}`],
|
|
651
|
+
});
|
|
652
|
+
Object.defineProperty(this, "name", {
|
|
653
|
+
enumerable: true,
|
|
654
|
+
configurable: true,
|
|
655
|
+
writable: true,
|
|
656
|
+
value: 'SignatureEnvelope.InvalidSerializedError'
|
|
657
|
+
});
|
|
658
|
+
}
|
|
659
|
+
}
|
|
660
|
+
//# sourceMappingURL=SignatureEnvelope.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SignatureEnvelope.js","sourceRoot":"","sources":["../../tempo/SignatureEnvelope.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,MAAM,mBAAmB,CAAA;AAC3C,OAAO,KAAK,GAAG,MAAM,gBAAgB,CAAA;AASrC,OAAO,KAAK,IAAI,MAAM,iBAAiB,CAAA;AAEvC,OAAO,KAAK,SAAS,MAAM,sBAAsB,CAAA;AAGjD,uDAAuD;AACvD,MAAM,kBAAkB,GAAG,MAAM,CAAA;AACjC,MAAM,sBAAsB,GAAG,MAAM,CAAA;AACrC,MAAM,sBAAsB,GAAG,MAAM,CAAA;AAwJrC,yCAAyC;AACzC,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,WAAW,EAAE,MAAM,EAAE,UAAU,CAAU,CAAA;AAK/D;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,UAAU,MAAM,CAAC,QAA8C;IACnE,MAAM,IAAI,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAA;IAE9B,IAAI,IAAI,KAAK,WAAW,EAAE,CAAC;QACzB,MAAM,SAAS,GAAG,QAAqB,CAAA;QACvC,SAAS,CAAC,MAAM,CAAC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