ox 1.7.4 → 1.8.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 +22 -0
- package/dist/core/AbiEvent.d.ts.map +1 -1
- package/dist/core/AbiEvent.js +10 -9
- package/dist/core/AbiEvent.js.map +1 -1
- package/dist/core/Blobs.d.ts.map +1 -1
- package/dist/core/Blobs.js +6 -2
- package/dist/core/Blobs.js.map +1 -1
- package/dist/core/Frame.d.ts +290 -0
- package/dist/core/Frame.d.ts.map +1 -0
- package/dist/core/Frame.js +306 -0
- package/dist/core/Frame.js.map +1 -0
- package/dist/core/FrameReceipt.d.ts +92 -0
- package/dist/core/FrameReceipt.d.ts.map +1 -0
- package/dist/core/FrameReceipt.js +72 -0
- package/dist/core/FrameReceipt.js.map +1 -0
- package/dist/core/FrameSignature.d.ts +357 -0
- package/dist/core/FrameSignature.d.ts.map +1 -0
- package/dist/core/FrameSignature.js +411 -0
- package/dist/core/FrameSignature.js.map +1 -0
- package/dist/core/Signature.d.ts +6 -5
- package/dist/core/Signature.d.ts.map +1 -1
- package/dist/core/Signature.js +17 -7
- package/dist/core/Signature.js.map +1 -1
- package/dist/core/Siwe.d.ts.map +1 -1
- package/dist/core/Siwe.js +21 -1
- package/dist/core/Siwe.js.map +1 -1
- package/dist/core/Transaction.d.ts +29 -4
- package/dist/core/Transaction.d.ts.map +1 -1
- package/dist/core/Transaction.js +25 -4
- package/dist/core/Transaction.js.map +1 -1
- package/dist/core/TransactionReceipt.d.ts +13 -4
- package/dist/core/TransactionReceipt.d.ts.map +1 -1
- package/dist/core/TransactionReceipt.js +14 -0
- package/dist/core/TransactionReceipt.js.map +1 -1
- package/dist/core/TransactionRequest.d.ts +15 -7
- package/dist/core/TransactionRequest.d.ts.map +1 -1
- package/dist/core/TransactionRequest.js +47 -1
- package/dist/core/TransactionRequest.js.map +1 -1
- package/dist/core/TxEnvelope.d.ts +35 -21
- package/dist/core/TxEnvelope.d.ts.map +1 -1
- package/dist/core/TxEnvelope.js +46 -6
- package/dist/core/TxEnvelope.js.map +1 -1
- package/dist/core/TxEnvelopeEip8141.d.ts +341 -0
- package/dist/core/TxEnvelopeEip8141.d.ts.map +1 -0
- package/dist/core/TxEnvelopeEip8141.js +485 -0
- package/dist/core/TxEnvelopeEip8141.js.map +1 -0
- package/dist/core/internal/curves.d.ts +2 -0
- package/dist/core/internal/curves.d.ts.map +1 -1
- package/dist/core/internal/curves.js +2 -0
- package/dist/core/internal/curves.js.map +1 -1
- package/dist/index.d.ts +73 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +73 -0
- package/dist/index.js.map +1 -1
- package/dist/tempo/KeyAuthorization.d.ts +42 -38
- package/dist/tempo/KeyAuthorization.d.ts.map +1 -1
- package/dist/tempo/KeyAuthorization.js +24 -4
- package/dist/tempo/KeyAuthorization.js.map +1 -1
- package/dist/tempo/MultisigConfig.d.ts +18 -15
- package/dist/tempo/MultisigConfig.d.ts.map +1 -1
- package/dist/tempo/MultisigConfig.js +49 -20
- package/dist/tempo/MultisigConfig.js.map +1 -1
- package/dist/tempo/MultisigOperation.d.ts +3 -2
- package/dist/tempo/MultisigOperation.d.ts.map +1 -1
- package/dist/tempo/MultisigOperation.js +20 -100
- package/dist/tempo/MultisigOperation.js.map +1 -1
- package/dist/tempo/MultisigSimulation.d.ts +2 -49
- package/dist/tempo/MultisigSimulation.d.ts.map +1 -1
- package/dist/tempo/MultisigSimulation.js +18 -46
- package/dist/tempo/MultisigSimulation.js.map +1 -1
- package/dist/tempo/SignatureEnvelope.d.ts +72 -140
- package/dist/tempo/SignatureEnvelope.d.ts.map +1 -1
- package/dist/tempo/SignatureEnvelope.js +130 -181
- package/dist/tempo/SignatureEnvelope.js.map +1 -1
- package/dist/tempo/Transaction.d.ts +2 -0
- package/dist/tempo/Transaction.d.ts.map +1 -1
- package/dist/tempo/TransactionReceipt.d.ts +2 -0
- package/dist/tempo/TransactionReceipt.d.ts.map +1 -1
- package/dist/tempo/TransactionRequest.d.ts +4 -2
- package/dist/tempo/TransactionRequest.d.ts.map +1 -1
- package/dist/tempo/TransactionRequest.js +6 -1
- package/dist/tempo/TransactionRequest.js.map +1 -1
- package/dist/tempo/index.d.ts +3 -1
- package/dist/tempo/index.d.ts.map +1 -1
- package/dist/tempo/index.js +3 -1
- package/dist/tempo/index.js.map +1 -1
- package/dist/zod/Block.d.ts +123 -0
- package/dist/zod/Block.d.ts.map +1 -1
- package/dist/zod/Frame.d.ts +73 -0
- package/dist/zod/Frame.d.ts.map +1 -0
- package/dist/zod/Frame.js +74 -0
- package/dist/zod/Frame.js.map +1 -0
- package/dist/zod/FrameReceipt.d.ts +50 -0
- package/dist/zod/FrameReceipt.d.ts.map +1 -0
- package/dist/zod/FrameReceipt.js +37 -0
- package/dist/zod/FrameReceipt.js.map +1 -0
- package/dist/zod/FrameSignature.d.ts +63 -0
- package/dist/zod/FrameSignature.d.ts.map +1 -0
- package/dist/zod/FrameSignature.js +66 -0
- package/dist/zod/FrameSignature.js.map +1 -0
- package/dist/zod/RpcSchema.d.ts +806 -11
- package/dist/zod/RpcSchema.d.ts.map +1 -1
- package/dist/zod/Transaction.d.ts +252 -0
- package/dist/zod/Transaction.d.ts.map +1 -1
- package/dist/zod/Transaction.js +54 -0
- package/dist/zod/Transaction.js.map +1 -1
- package/dist/zod/TransactionEnvelope.d.ts +233 -4
- package/dist/zod/TransactionEnvelope.d.ts.map +1 -1
- package/dist/zod/TransactionEnvelope.js +9 -0
- package/dist/zod/TransactionEnvelope.js.map +1 -1
- package/dist/zod/TransactionReceipt.d.ts +48 -0
- package/dist/zod/TransactionReceipt.d.ts.map +1 -1
- package/dist/zod/TransactionReceipt.js +8 -3
- package/dist/zod/TransactionReceipt.js.map +1 -1
- package/dist/zod/TransactionRequest.d.ts +50 -2
- package/dist/zod/TransactionRequest.d.ts.map +1 -1
- package/dist/zod/TransactionRequest.js +10 -4
- package/dist/zod/TransactionRequest.js.map +1 -1
- package/dist/zod/TxEnvelopeEip8141.d.ts +166 -0
- package/dist/zod/TxEnvelopeEip8141.d.ts.map +1 -0
- package/dist/zod/TxEnvelopeEip8141.js +76 -0
- package/dist/zod/TxEnvelopeEip8141.js.map +1 -0
- package/dist/zod/internal/Frame.d.ts +4 -0
- package/dist/zod/internal/Frame.d.ts.map +1 -0
- package/dist/zod/internal/Frame.js +17 -0
- package/dist/zod/internal/Frame.js.map +1 -0
- package/dist/zod/internal/rpcSchemas/Eth.d.ts +842 -11
- package/dist/zod/internal/rpcSchemas/Eth.d.ts.map +1 -1
- package/dist/zod/internal/rpcSchemas/Wallet.d.ts +56 -2
- package/dist/zod/internal/rpcSchemas/Wallet.d.ts.map +1 -1
- package/dist/zod/tempo/AuthorizationTempo.d.ts +350 -10
- package/dist/zod/tempo/AuthorizationTempo.d.ts.map +1 -1
- package/dist/zod/tempo/KeyAuthorization.d.ts +242 -422
- package/dist/zod/tempo/KeyAuthorization.d.ts.map +1 -1
- package/dist/zod/tempo/KeyAuthorization.js +29 -31
- package/dist/zod/tempo/KeyAuthorization.js.map +1 -1
- package/dist/zod/tempo/MultisigSimulation.d.ts +8 -76
- package/dist/zod/tempo/MultisigSimulation.d.ts.map +1 -1
- package/dist/zod/tempo/MultisigSimulation.js +3 -37
- package/dist/zod/tempo/MultisigSimulation.js.map +1 -1
- package/dist/zod/tempo/RpcSchemaTempo.d.ts +424 -228
- package/dist/zod/tempo/RpcSchemaTempo.d.ts.map +1 -1
- package/dist/zod/tempo/SignatureEnvelope.d.ts +105 -3
- package/dist/zod/tempo/SignatureEnvelope.d.ts.map +1 -1
- package/dist/zod/tempo/SignatureEnvelope.js +21 -9
- package/dist/zod/tempo/SignatureEnvelope.js.map +1 -1
- package/dist/zod/tempo/Transaction.d.ts +783 -432
- package/dist/zod/tempo/Transaction.d.ts.map +1 -1
- package/dist/zod/tempo/TransactionRequest.d.ts +590 -473
- package/dist/zod/tempo/TransactionRequest.d.ts.map +1 -1
- package/dist/zod/tempo/TransactionRequest.js +8 -0
- package/dist/zod/tempo/TransactionRequest.js.map +1 -1
- package/dist/zod/tempo/TxEnvelopeTempo.d.ts +327 -213
- package/dist/zod/tempo/TxEnvelopeTempo.d.ts.map +1 -1
- package/dist/zod/tempo/ZoneRpcAuthentication.d.ts +105 -3
- package/dist/zod/tempo/ZoneRpcAuthentication.d.ts.map +1 -1
- package/dist/zod/z.d.ts +4 -0
- package/dist/zod/z.d.ts.map +1 -1
- package/dist/zod/z.js +4 -0
- package/dist/zod/z.js.map +1 -1
- package/package.json +41 -1
- package/src/core/AbiEvent.ts +11 -9
- package/src/core/Blobs.ts +6 -2
- package/src/core/Frame.ts +443 -0
- package/src/core/FrameReceipt.ts +117 -0
- package/src/core/FrameSignature.ts +593 -0
- package/src/core/Signature.ts +41 -11
- package/src/core/Siwe.ts +20 -1
- package/src/core/Transaction.ts +82 -5
- package/src/core/TransactionReceipt.ts +41 -3
- package/src/core/TransactionRequest.ts +71 -4
- package/src/core/TxEnvelope.ts +159 -90
- package/src/core/TxEnvelopeEip8141.ts +715 -0
- package/src/core/_test/AbiEvent.test.ts +45 -0
- package/src/core/_test/Blobs.test.ts +22 -0
- package/src/core/_test/Frame.test-d.ts +96 -0
- package/src/core/_test/Frame.test.ts +267 -0
- package/src/core/_test/FrameReceipt.test.ts +86 -0
- package/src/core/_test/FrameSignature.test-d.ts +93 -0
- package/src/core/_test/FrameSignature.test.ts +554 -0
- package/src/core/_test/Signature.test.ts +166 -0
- package/src/core/_test/Siwe.test.ts +100 -1
- package/src/core/_test/Transaction.test.ts +33 -0
- package/src/core/_test/TransactionEnvelope.test-d.ts +74 -0
- package/src/core/_test/TransactionEnvelope.test.ts +107 -0
- package/src/core/_test/TransactionReceipt.test.ts +59 -0
- package/src/core/_test/TransactionRequest.test-d.ts +50 -0
- package/src/core/_test/TransactionRequest.test.ts +88 -1
- package/src/core/_test/TxEnvelopeEip8141.test-d.ts +44 -0
- package/src/core/_test/TxEnvelopeEip8141.test.ts +1775 -0
- package/src/core/_test/curves.test.ts +6 -1
- package/src/core/_test/index.test.ts +4 -0
- package/src/core/internal/curves.ts +4 -0
- package/src/index.ts +77 -0
- package/src/tempo/AuthorizationTempo.test.ts +8 -4
- package/src/tempo/KeyAuthorization.test-d.ts +16 -63
- package/src/tempo/KeyAuthorization.test.ts +69 -11
- package/src/tempo/KeyAuthorization.ts +107 -63
- package/src/tempo/MultisigConfig.test.ts +44 -20
- package/src/tempo/MultisigConfig.ts +65 -23
- package/src/tempo/MultisigOperation.test.ts +79 -550
- package/src/tempo/MultisigOperation.ts +31 -146
- package/src/tempo/MultisigSimulation.test-d.ts +2 -2
- package/src/tempo/MultisigSimulation.test.ts +21 -110
- package/src/tempo/MultisigSimulation.ts +25 -99
- package/src/tempo/SignatureEnvelope.test-d.ts +29 -47
- package/src/tempo/SignatureEnvelope.test.ts +328 -541
- package/src/tempo/SignatureEnvelope.ts +196 -291
- package/src/tempo/Transaction.test.ts +4 -4
- package/src/tempo/TransactionRequest.test.ts +17 -80
- package/src/tempo/TransactionRequest.ts +19 -2
- package/src/tempo/index.ts +3 -1
- package/src/tempo/multisig.e2e.test.ts +321 -860
- package/src/version.ts +1 -1
- package/src/zod/Frame.ts +82 -0
- package/src/zod/FrameReceipt.ts +48 -0
- package/src/zod/FrameSignature.ts +78 -0
- package/src/zod/Transaction.ts +63 -0
- package/src/zod/TransactionEnvelope.ts +33 -0
- package/src/zod/TransactionReceipt.ts +14 -3
- package/src/zod/TransactionRequest.ts +18 -3
- package/src/zod/TxEnvelopeEip8141.ts +102 -0
- package/src/zod/_test/Frame.test-d.ts +41 -0
- package/src/zod/_test/Frame.test.ts +54 -0
- package/src/zod/_test/FrameReceipt.test.ts +75 -0
- package/src/zod/_test/FrameSignature.test.ts +94 -0
- package/src/zod/_test/TxEnvelopeEip8141.test.ts +116 -0
- package/src/zod/internal/Frame.ts +26 -0
- package/src/zod/tempo/KeyAuthorization.ts +50 -39
- package/src/zod/tempo/MultisigSimulation.ts +3 -48
- package/src/zod/tempo/SignatureEnvelope.ts +46 -35
- package/src/zod/tempo/TransactionRequest.ts +14 -0
- package/src/zod/tempo/_test/KeyAuthorization.test.ts +69 -20
- package/src/zod/tempo/_test/MultisigSimulation.test.ts +6 -31
- package/src/zod/tempo/_test/SignatureEnvelope.test.ts +118 -85
- package/src/zod/tempo/_test/TransactionRequest.test.ts +9 -19
- package/src/zod/z.ts +4 -0
|
@@ -0,0 +1,357 @@
|
|
|
1
|
+
import * as Address from './Address.js';
|
|
2
|
+
import * as Errors from './Errors.js';
|
|
3
|
+
import * as Hex from './Hex.js';
|
|
4
|
+
import type { Compute, UnionPartialBy } from './internal/types.js';
|
|
5
|
+
import * as PublicKey from './PublicKey.js';
|
|
6
|
+
import * as Signature from './Signature.js';
|
|
7
|
+
/** Signature schemes supported by EIP-8141. */
|
|
8
|
+
export declare const schemes: {
|
|
9
|
+
readonly arbitrary: 0;
|
|
10
|
+
readonly p256: 2;
|
|
11
|
+
readonly secp256k1: 1;
|
|
12
|
+
};
|
|
13
|
+
/** A supported numeric or named frame signature scheme. */
|
|
14
|
+
export type Scheme = keyof typeof schemes | (typeof schemes)[keyof typeof schemes];
|
|
15
|
+
/** Contract-defined signature bytes. */
|
|
16
|
+
export type Arbitrary = {
|
|
17
|
+
/** Explicit nonzero digest. Omit or use empty bytes for the transaction signing hash. */
|
|
18
|
+
payload?: Hex.Hex | undefined;
|
|
19
|
+
/** Contract-defined verification scheme. */
|
|
20
|
+
scheme: 0 | 'arbitrary';
|
|
21
|
+
/** Opaque witness bytes. */
|
|
22
|
+
signature: Hex.Hex;
|
|
23
|
+
/** Arbitrary signatures have no signer metadata. */
|
|
24
|
+
signer?: undefined;
|
|
25
|
+
};
|
|
26
|
+
/** A structured secp256k1 signature entry. */
|
|
27
|
+
export type Secp256k1 = {
|
|
28
|
+
/** Explicit nonzero digest. Omit or use empty bytes for the transaction signing hash. */
|
|
29
|
+
payload?: Hex.Hex | undefined;
|
|
30
|
+
/** secp256k1 verification scheme. */
|
|
31
|
+
scheme: 1 | 'secp256k1';
|
|
32
|
+
/** Recovered signature. Omit for an unsigned entry. */
|
|
33
|
+
signature?: Signature.Signature | undefined;
|
|
34
|
+
/** Signer address. Omit to use the transaction sender. */
|
|
35
|
+
signer?: Address.Address | undefined;
|
|
36
|
+
};
|
|
37
|
+
/** A structured P-256 signature entry. */
|
|
38
|
+
export type P256 = {
|
|
39
|
+
/** Explicit nonzero digest. Omit or use empty bytes for the transaction signing hash. */
|
|
40
|
+
payload?: Hex.Hex | undefined;
|
|
41
|
+
/** P-256 verification scheme. */
|
|
42
|
+
scheme: 2 | 'p256';
|
|
43
|
+
/** Signer address. Omit to use the transaction sender. */
|
|
44
|
+
signer?: Address.Address | undefined;
|
|
45
|
+
} & ({
|
|
46
|
+
/** Uncompressed P-256 public key. */
|
|
47
|
+
publicKey: PublicKey.PublicKey;
|
|
48
|
+
/** P-256 signature. */
|
|
49
|
+
signature: Signature.Signature<false>;
|
|
50
|
+
} | {
|
|
51
|
+
/** Public key, if already known. Empty wire signatures do not retain it. */
|
|
52
|
+
publicKey?: PublicKey.PublicKey | undefined;
|
|
53
|
+
/** Omit for an unsigned entry. */
|
|
54
|
+
signature?: undefined;
|
|
55
|
+
});
|
|
56
|
+
/** An EIP-8141 signature entry. Empty payload selects the transaction signing hash. */
|
|
57
|
+
export type FrameSignature = Arbitrary | Secp256k1 | P256;
|
|
58
|
+
/** JSON-RPC representation of a frame signature. */
|
|
59
|
+
export type Rpc = {
|
|
60
|
+
/** Explicit digest, or empty bytes for the transaction signing hash. */
|
|
61
|
+
msg: Hex.Hex;
|
|
62
|
+
/** Signature verification scheme. */
|
|
63
|
+
scheme: 0 | 1 | 2;
|
|
64
|
+
/** Encoded signature bytes. */
|
|
65
|
+
signature: Hex.Hex;
|
|
66
|
+
/** Signer address; absent for the transaction sender. */
|
|
67
|
+
signer?: Address.Address | null | undefined;
|
|
68
|
+
};
|
|
69
|
+
/** RLP-ready signature entry. The payload occupies the specification's `msg` field. */
|
|
70
|
+
export type Tuple = readonly [
|
|
71
|
+
scheme: Hex.Hex,
|
|
72
|
+
signer: Hex.Hex,
|
|
73
|
+
payload: Hex.Hex,
|
|
74
|
+
signature: Hex.Hex
|
|
75
|
+
];
|
|
76
|
+
/**
|
|
77
|
+
* Asserts that a {@link ox#FrameSignature.FrameSignature} is structurally valid.
|
|
78
|
+
*
|
|
79
|
+
* Checks metadata, signature scalars, and public key shape without verifying
|
|
80
|
+
* authorization.
|
|
81
|
+
*
|
|
82
|
+
* @example
|
|
83
|
+
* ### Basic Usage
|
|
84
|
+
*
|
|
85
|
+
* Unsigned protocol entries are accepted by default.
|
|
86
|
+
*
|
|
87
|
+
* ```ts twoslash
|
|
88
|
+
* import { FrameSignature } from 'ox'
|
|
89
|
+
*
|
|
90
|
+
* FrameSignature.assert({
|
|
91
|
+
* payload: '0x',
|
|
92
|
+
* scheme: 'secp256k1'
|
|
93
|
+
* })
|
|
94
|
+
* ```
|
|
95
|
+
*
|
|
96
|
+
* @example
|
|
97
|
+
* ### Requiring a Signature
|
|
98
|
+
*
|
|
99
|
+
* Set `signed` to require a protocol signature.
|
|
100
|
+
*
|
|
101
|
+
* ```ts twoslash
|
|
102
|
+
* import { FrameSignature, Hash, Secp256k1 } from 'ox'
|
|
103
|
+
*
|
|
104
|
+
* const payload = Hash.keccak256('0xdeadbeef')
|
|
105
|
+
* const privateKey = Secp256k1.randomPrivateKey()
|
|
106
|
+
* const signature = Secp256k1.sign({ payload, privateKey })
|
|
107
|
+
*
|
|
108
|
+
* const entry = FrameSignature.from({
|
|
109
|
+
* payload,
|
|
110
|
+
* scheme: 'secp256k1',
|
|
111
|
+
* signature
|
|
112
|
+
* })
|
|
113
|
+
*
|
|
114
|
+
* FrameSignature.assert(entry, { signed: true })
|
|
115
|
+
* ```
|
|
116
|
+
*
|
|
117
|
+
* @param entry - The signature entry to assert.
|
|
118
|
+
* @param options - Validation options.
|
|
119
|
+
*/
|
|
120
|
+
export declare function assert(entry: FrameSignature, options?: assert.Options): void;
|
|
121
|
+
export declare namespace assert {
|
|
122
|
+
type Options = {
|
|
123
|
+
/**
|
|
124
|
+
* Require a protocol signature. Does not perform cryptographic verification.
|
|
125
|
+
* @default false
|
|
126
|
+
*/
|
|
127
|
+
signed?: boolean | undefined;
|
|
128
|
+
};
|
|
129
|
+
type ErrorType = InvalidError | Address.assert.ErrorType | Hex.assert.ErrorType | Hex.toBigInt.ErrorType | PublicKey.assert.ErrorType | Signature.assert.ErrorType | Errors.GlobalErrorType;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Coerces a value into a {@link ox#FrameSignature.FrameSignature}.
|
|
133
|
+
*
|
|
134
|
+
* Accepts arbitrary signature bytes or a structured signature entry. Omitted
|
|
135
|
+
* `scheme` and `payload` default to `'arbitrary'` and `'0x'`, respectively.
|
|
136
|
+
* An empty payload selects the canonical transaction signing hash; an explicit
|
|
137
|
+
* payload must be a nonzero 32-byte digest.
|
|
138
|
+
*
|
|
139
|
+
* @example
|
|
140
|
+
* ### From Hex
|
|
141
|
+
*
|
|
142
|
+
* Wrap arbitrary witness bytes for contract-defined verification.
|
|
143
|
+
*
|
|
144
|
+
* ```ts twoslash
|
|
145
|
+
* import { FrameSignature } from 'ox'
|
|
146
|
+
*
|
|
147
|
+
* const entry = FrameSignature.from('0xaabb')
|
|
148
|
+
* // @log: { payload: '0x', scheme: 'arbitrary', signature: '0xaabb' }
|
|
149
|
+
* ```
|
|
150
|
+
*
|
|
151
|
+
* @example
|
|
152
|
+
* ### Secp256k1
|
|
153
|
+
*
|
|
154
|
+
* Wrap a signature over an explicit digest, retaining the same payload in the entry.
|
|
155
|
+
*
|
|
156
|
+
* ```ts twoslash
|
|
157
|
+
* import { FrameSignature, Hash, Secp256k1 } from 'ox'
|
|
158
|
+
*
|
|
159
|
+
* const payload = Hash.keccak256('0xdeadbeef')
|
|
160
|
+
* const privateKey = Secp256k1.randomPrivateKey()
|
|
161
|
+
* const signature = Secp256k1.sign({ payload, privateKey })
|
|
162
|
+
*
|
|
163
|
+
* const entry = FrameSignature.from({
|
|
164
|
+
* payload,
|
|
165
|
+
* scheme: 'secp256k1',
|
|
166
|
+
* signature
|
|
167
|
+
* })
|
|
168
|
+
* ```
|
|
169
|
+
*
|
|
170
|
+
* @example
|
|
171
|
+
* ### P256
|
|
172
|
+
*
|
|
173
|
+
* Include the public key with a P-256 signature over an explicit digest.
|
|
174
|
+
*
|
|
175
|
+
* ```ts twoslash
|
|
176
|
+
* import { FrameSignature, Hash, P256 } from 'ox'
|
|
177
|
+
*
|
|
178
|
+
* const { privateKey, publicKey } = P256.createKeyPair()
|
|
179
|
+
* const payload = Hash.keccak256('0xdeadbeef')
|
|
180
|
+
* const signature = P256.sign({ payload, privateKey })
|
|
181
|
+
*
|
|
182
|
+
* const entry = FrameSignature.from({
|
|
183
|
+
* payload,
|
|
184
|
+
* publicKey,
|
|
185
|
+
* scheme: 'p256',
|
|
186
|
+
* signature
|
|
187
|
+
* })
|
|
188
|
+
* ```
|
|
189
|
+
*
|
|
190
|
+
* @example
|
|
191
|
+
* ### Unsigned Entries
|
|
192
|
+
*
|
|
193
|
+
* Omit the signature to prepare a protocol entry before signing the transaction.
|
|
194
|
+
*
|
|
195
|
+
* ```ts twoslash
|
|
196
|
+
* import { FrameSignature } from 'ox'
|
|
197
|
+
*
|
|
198
|
+
* const entry = FrameSignature.from({ scheme: 'secp256k1' })
|
|
199
|
+
* // @log: { payload: '0x', scheme: 'secp256k1' }
|
|
200
|
+
* ```
|
|
201
|
+
*
|
|
202
|
+
* @param entry - Arbitrary signature bytes or a structured signature entry.
|
|
203
|
+
* @returns The validated entry, preserving supplied signature and scheme types.
|
|
204
|
+
*/
|
|
205
|
+
export declare function from<const entry extends from.Input>(entry: entry | from.Input): from.ReturnType<entry>;
|
|
206
|
+
export declare namespace from {
|
|
207
|
+
type Input = Hex.Hex | UnionPartialBy<Arbitrary, 'scheme' | 'payload'> | UnionPartialBy<Secp256k1 | P256, 'payload'>;
|
|
208
|
+
type ReturnType<entry extends Input = Input> = entry extends Hex.Hex ? {
|
|
209
|
+
payload: '0x';
|
|
210
|
+
scheme: 'arbitrary';
|
|
211
|
+
signature: entry;
|
|
212
|
+
} : entry extends Input ? Compute<Omit<entry, 'scheme' | 'payload'> & {
|
|
213
|
+
payload: entry extends {
|
|
214
|
+
payload: infer payload extends Hex.Hex;
|
|
215
|
+
} ? payload : 'payload' extends keyof entry ? Exclude<entry['payload'], undefined> | '0x' : '0x';
|
|
216
|
+
scheme: entry extends {
|
|
217
|
+
scheme: infer scheme extends Scheme;
|
|
218
|
+
} ? scheme : 'scheme' extends keyof entry ? Exclude<entry['scheme'], undefined> | 'arbitrary' : 'arbitrary';
|
|
219
|
+
}> : never;
|
|
220
|
+
type ErrorType = assert.ErrorType;
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* Converts an RPC signature entry to a structured frame signature.
|
|
224
|
+
*
|
|
225
|
+
* @example
|
|
226
|
+
* ### Basic Usage
|
|
227
|
+
*
|
|
228
|
+
* ```ts twoslash
|
|
229
|
+
* import { FrameSignature } from 'ox'
|
|
230
|
+
*
|
|
231
|
+
* const entry = FrameSignature.fromRpc({
|
|
232
|
+
* msg: '0x',
|
|
233
|
+
* scheme: 0,
|
|
234
|
+
* signature: '0xdeadbeef'
|
|
235
|
+
* })
|
|
236
|
+
* ```
|
|
237
|
+
*
|
|
238
|
+
* @param entry - The value to convert.
|
|
239
|
+
* @returns The converted value.
|
|
240
|
+
*/
|
|
241
|
+
export declare function fromRpc(entry: Rpc): FrameSignature;
|
|
242
|
+
export declare namespace fromRpc {
|
|
243
|
+
type ErrorType = fromTuple.ErrorType | Hex.fromNumber.ErrorType;
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* Converts a structured frame signature to its RPC representation.
|
|
247
|
+
*
|
|
248
|
+
* @example
|
|
249
|
+
* ### Basic Usage
|
|
250
|
+
*
|
|
251
|
+
* ```ts twoslash
|
|
252
|
+
* import { FrameSignature } from 'ox'
|
|
253
|
+
*
|
|
254
|
+
* const entry = FrameSignature.from('0xdeadbeef')
|
|
255
|
+
* const rpc = FrameSignature.toRpc(entry)
|
|
256
|
+
* ```
|
|
257
|
+
*
|
|
258
|
+
* @param entry - The value to convert.
|
|
259
|
+
* @returns The converted value.
|
|
260
|
+
*/
|
|
261
|
+
export declare function toRpc(entry: FrameSignature): Rpc;
|
|
262
|
+
export declare namespace toRpc {
|
|
263
|
+
type ErrorType = toTuple.ErrorType | Hex.toNumber.ErrorType;
|
|
264
|
+
}
|
|
265
|
+
/**
|
|
266
|
+
* Converts a {@link ox#FrameSignature.Tuple} to a structured
|
|
267
|
+
* {@link ox#FrameSignature.FrameSignature}.
|
|
268
|
+
*
|
|
269
|
+
* Returns a named scheme and unpacks protocol signatures. Empty protocol signatures
|
|
270
|
+
* become unsigned entries. Rejects noncanonical encodings.
|
|
271
|
+
*
|
|
272
|
+
* @example
|
|
273
|
+
* ### Basic Usage
|
|
274
|
+
*
|
|
275
|
+
* Decode an arbitrary signature tuple.
|
|
276
|
+
*
|
|
277
|
+
* ```ts twoslash
|
|
278
|
+
* import { FrameSignature } from 'ox'
|
|
279
|
+
*
|
|
280
|
+
* const entry = FrameSignature.fromTuple([
|
|
281
|
+
* '0x',
|
|
282
|
+
* '0x',
|
|
283
|
+
* '0x',
|
|
284
|
+
* '0xaabb'
|
|
285
|
+
* ])
|
|
286
|
+
* // @log: { payload: '0x', scheme: 'arbitrary', signature: '0xaabb' }
|
|
287
|
+
* ```
|
|
288
|
+
*
|
|
289
|
+
* @param tuple - The signature tuple to convert.
|
|
290
|
+
* @returns The decoded signature entry.
|
|
291
|
+
*/
|
|
292
|
+
export declare function fromTuple(tuple: Tuple): FrameSignature;
|
|
293
|
+
export declare namespace fromTuple {
|
|
294
|
+
type ErrorType = assert.ErrorType | Hex.slice.ErrorType | Hex.toNumber.ErrorType | Hex.toBytes.ErrorType | Signature.fromRecoveredBytes.ErrorType;
|
|
295
|
+
}
|
|
296
|
+
/**
|
|
297
|
+
* Converts a {@link ox#FrameSignature.FrameSignature} to its RLP-ready
|
|
298
|
+
* {@link ox#FrameSignature.Tuple}.
|
|
299
|
+
*
|
|
300
|
+
* Encodes numeric scheme identifiers and packs protocol signatures without mutating
|
|
301
|
+
* the entry. Omitted protocol signatures become empty bytes.
|
|
302
|
+
*
|
|
303
|
+
* @example
|
|
304
|
+
* ### Basic Usage
|
|
305
|
+
*
|
|
306
|
+
* Encode arbitrary witness bytes with the default scheme and payload.
|
|
307
|
+
*
|
|
308
|
+
* ```ts twoslash
|
|
309
|
+
* import { FrameSignature } from 'ox'
|
|
310
|
+
*
|
|
311
|
+
* const entry = FrameSignature.from('0xaabb')
|
|
312
|
+
* const tuple = FrameSignature.toTuple(entry)
|
|
313
|
+
* // @log: ['0x', '0x', '0x', '0xaabb']
|
|
314
|
+
* ```
|
|
315
|
+
*
|
|
316
|
+
* @param entry - The signature entry to convert.
|
|
317
|
+
* @returns The encoded signature tuple.
|
|
318
|
+
*/
|
|
319
|
+
export declare function toTuple(entry: FrameSignature): Tuple;
|
|
320
|
+
export declare namespace toTuple {
|
|
321
|
+
type ErrorType = assert.ErrorType | Hex.fromNumber.ErrorType | Hex.fromBytes.ErrorType | Hex.concat.ErrorType | Signature.toRecoveredBytes.ErrorType;
|
|
322
|
+
}
|
|
323
|
+
/**
|
|
324
|
+
* Returns whether a {@link ox#FrameSignature.FrameSignature} is structurally valid.
|
|
325
|
+
*
|
|
326
|
+
* Performs the same checks as {@link ox#FrameSignature.(assert:function)}, returning
|
|
327
|
+
* `false` instead of throwing. Does not verify that the signature authorizes a payload.
|
|
328
|
+
*
|
|
329
|
+
* @example
|
|
330
|
+
* ### Basic Usage
|
|
331
|
+
*
|
|
332
|
+
* Require a signature when checking a protocol entry.
|
|
333
|
+
*
|
|
334
|
+
* ```ts twoslash
|
|
335
|
+
* import { FrameSignature } from 'ox'
|
|
336
|
+
*
|
|
337
|
+
* const entry = FrameSignature.from({ scheme: 'secp256k1' })
|
|
338
|
+
* const valid = FrameSignature.validate(entry, {
|
|
339
|
+
* signed: true
|
|
340
|
+
* })
|
|
341
|
+
* // @log: false
|
|
342
|
+
* ```
|
|
343
|
+
*
|
|
344
|
+
* @param entry - The signature entry to validate.
|
|
345
|
+
* @param options - Validation options.
|
|
346
|
+
* @returns Whether the entry is structurally valid.
|
|
347
|
+
*/
|
|
348
|
+
export declare function validate(entry: FrameSignature, options?: assert.Options): boolean;
|
|
349
|
+
export declare namespace validate {
|
|
350
|
+
type ErrorType = Errors.GlobalErrorType;
|
|
351
|
+
}
|
|
352
|
+
/** Thrown when frame signature metadata or encoding is invalid. */
|
|
353
|
+
export declare class InvalidError extends Errors.BaseError {
|
|
354
|
+
readonly name = "FrameSignature.InvalidError";
|
|
355
|
+
constructor(details: string);
|
|
356
|
+
}
|
|
357
|
+
//# sourceMappingURL=FrameSignature.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FrameSignature.d.ts","sourceRoot":"","sources":["../../src/core/FrameSignature.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,cAAc,CAAA;AACvC,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA;AACrC,OAAO,KAAK,GAAG,MAAM,UAAU,CAAA;AAE/B,OAAO,KAAK,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AAClE,OAAO,KAAK,SAAS,MAAM,gBAAgB,CAAA;AAC3C,OAAO,KAAK,SAAS,MAAM,gBAAgB,CAAA;AAE3C,+CAA+C;AAC/C,eAAO,MAAM,OAAO;;;;CAAmD,CAAA;AAEvE,2DAA2D;AAC3D,MAAM,MAAM,MAAM,GACd,MAAM,OAAO,OAAO,GACpB,CAAC,OAAO,OAAO,CAAC,CAAC,MAAM,OAAO,OAAO,CAAC,CAAA;AAE1C,wCAAwC;AACxC,MAAM,MAAM,SAAS,GAAG;IACtB,yFAAyF;IACzF,OAAO,CAAC,EAAE,GAAG,CAAC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