ox 0.14.5 → 0.14.7
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 +12 -0
- package/_cjs/tempo/AuthorizationTempo.js.map +1 -1
- package/_cjs/tempo/KeyAuthorization.js.map +1 -1
- package/_cjs/tempo/PoolId.js.map +1 -1
- package/_cjs/tempo/TempoAddress.js.map +1 -1
- package/_cjs/tempo/TokenId.js.map +1 -1
- package/_cjs/tempo/TxEnvelopeTempo.js.map +1 -1
- package/_cjs/version.js +1 -1
- package/_cjs/webauthn/Authentication.js +8 -1
- package/_cjs/webauthn/Authentication.js.map +1 -1
- package/_cjs/webauthn/Credential.js +8 -1
- package/_cjs/webauthn/Credential.js.map +1 -1
- package/_cjs/webauthn/Registration.js +8 -1
- package/_cjs/webauthn/Registration.js.map +1 -1
- package/_esm/tempo/AuthorizationTempo.js.map +1 -1
- package/_esm/tempo/KeyAuthorization.js.map +1 -1
- package/_esm/tempo/PoolId.js.map +1 -1
- package/_esm/tempo/TempoAddress.js.map +1 -1
- package/_esm/tempo/TokenId.js.map +1 -1
- package/_esm/tempo/TxEnvelopeTempo.js.map +1 -1
- package/_esm/version.js +1 -1
- package/_esm/webauthn/Authentication.js +8 -1
- package/_esm/webauthn/Authentication.js.map +1 -1
- package/_esm/webauthn/Credential.js +11 -1
- package/_esm/webauthn/Credential.js.map +1 -1
- package/_esm/webauthn/Registration.js +8 -1
- package/_esm/webauthn/Registration.js.map +1 -1
- package/_types/tempo/AuthorizationTempo.d.ts +4 -4
- package/_types/tempo/AuthorizationTempo.d.ts.map +1 -1
- package/_types/tempo/KeyAuthorization.d.ts +11 -9
- package/_types/tempo/KeyAuthorization.d.ts.map +1 -1
- package/_types/tempo/PoolId.d.ts +3 -2
- package/_types/tempo/PoolId.d.ts.map +1 -1
- package/_types/tempo/TempoAddress.d.ts +4 -0
- package/_types/tempo/TempoAddress.d.ts.map +1 -1
- package/_types/tempo/TokenId.d.ts +2 -2
- package/_types/tempo/TokenId.d.ts.map +1 -1
- package/_types/tempo/TransactionRequest.d.ts +1 -1
- package/_types/tempo/TransactionRequest.d.ts.map +1 -1
- package/_types/tempo/TxEnvelopeTempo.d.ts +9 -7
- package/_types/tempo/TxEnvelopeTempo.d.ts.map +1 -1
- package/_types/version.d.ts +1 -1
- package/_types/webauthn/Authentication.d.ts.map +1 -1
- package/_types/webauthn/Credential.d.ts.map +1 -1
- package/_types/webauthn/Registration.d.ts.map +1 -1
- package/package.json +1 -1
- package/tempo/AuthorizationTempo.test.ts +6 -6
- package/tempo/AuthorizationTempo.ts +8 -5
- package/tempo/KeyAuthorization.ts +26 -15
- package/tempo/PoolId.ts +3 -2
- package/tempo/TempoAddress.ts +9 -0
- package/tempo/TokenId.ts +6 -2
- package/tempo/TransactionRequest.ts +1 -1
- package/tempo/TxEnvelopeTempo.ts +25 -13
- package/version.ts +1 -1
- package/webauthn/Authentication.ts +8 -1
- package/webauthn/Credential.ts +11 -1
- package/webauthn/Registration.ts +8 -3
|
@@ -32,15 +32,16 @@ export type KeyAuthorization<
|
|
|
32
32
|
signed extends boolean = boolean,
|
|
33
33
|
bigintType = bigint,
|
|
34
34
|
numberType = number,
|
|
35
|
+
addressType = Address.Address,
|
|
35
36
|
> = {
|
|
36
37
|
/** Address derived from the public key of the key type. */
|
|
37
|
-
address:
|
|
38
|
+
address: addressType
|
|
38
39
|
/** Chain ID for replay protection. */
|
|
39
40
|
chainId: bigintType
|
|
40
41
|
/** Unix timestamp when key expires (0 = never expires). */
|
|
41
42
|
expiry?: numberType | null | undefined
|
|
42
43
|
/** TIP20 spending limits for this key. */
|
|
43
|
-
limits?: readonly TokenLimit<bigintType>[] | undefined
|
|
44
|
+
limits?: readonly TokenLimit<bigintType, addressType>[] | undefined
|
|
44
45
|
/** Key type. (secp256k1, P256, WebAuthn). */
|
|
45
46
|
type: SignatureEnvelope.Type
|
|
46
47
|
} & (signed extends true
|
|
@@ -51,6 +52,14 @@ export type KeyAuthorization<
|
|
|
51
52
|
| undefined
|
|
52
53
|
})
|
|
53
54
|
|
|
55
|
+
/** Input type for a Key Authorization. */
|
|
56
|
+
export type Input = KeyAuthorization<
|
|
57
|
+
false,
|
|
58
|
+
bigint,
|
|
59
|
+
number,
|
|
60
|
+
TempoAddress.Address
|
|
61
|
+
>
|
|
62
|
+
|
|
54
63
|
/** RPC representation of an {@link ox#KeyAuthorization.KeyAuthorization}. */
|
|
55
64
|
export type Rpc = Omit<
|
|
56
65
|
KeyAuthorization<false, Hex.Hex, Hex.Hex>,
|
|
@@ -62,11 +71,11 @@ export type Rpc = Omit<
|
|
|
62
71
|
}
|
|
63
72
|
|
|
64
73
|
/** Signed representation of a Key Authorization. */
|
|
65
|
-
export type Signed<
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
>
|
|
74
|
+
export type Signed<
|
|
75
|
+
bigintType = bigint,
|
|
76
|
+
numberType = number,
|
|
77
|
+
addressType = Address.Address,
|
|
78
|
+
> = KeyAuthorization<true, bigintType, numberType, addressType>
|
|
70
79
|
|
|
71
80
|
type BaseTuple = readonly [
|
|
72
81
|
chainId: Hex.Hex,
|
|
@@ -106,9 +115,9 @@ export type Tuple<signed extends boolean = boolean> = signed extends true
|
|
|
106
115
|
*
|
|
107
116
|
* [Access Keys Specification](https://docs.tempo.xyz/protocol/transactions/spec-tempo-transaction#access-keys)
|
|
108
117
|
*/
|
|
109
|
-
export type TokenLimit<bigintType = bigint> = {
|
|
118
|
+
export type TokenLimit<bigintType = bigint, addressType = Address.Address> = {
|
|
110
119
|
/** Address of the TIP-20 token. */
|
|
111
|
-
token:
|
|
120
|
+
token: addressType
|
|
112
121
|
/** Maximum spending amount for this token (enforced over the key's lifetime). */
|
|
113
122
|
limit: bigintType
|
|
114
123
|
}
|
|
@@ -250,7 +259,7 @@ export type TokenLimit<bigintType = bigint> = {
|
|
|
250
259
|
* @returns The {@link ox#KeyAuthorization.KeyAuthorization}.
|
|
251
260
|
*/
|
|
252
261
|
export function from<
|
|
253
|
-
const authorization extends
|
|
262
|
+
const authorization extends Input | Rpc,
|
|
254
263
|
const signature extends SignatureEnvelope.from.Value | undefined = undefined,
|
|
255
264
|
>(
|
|
256
265
|
authorization: authorization | KeyAuthorization,
|
|
@@ -291,17 +300,19 @@ export declare namespace from {
|
|
|
291
300
|
}
|
|
292
301
|
|
|
293
302
|
type ReturnType<
|
|
294
|
-
authorization extends KeyAuthorization | Rpc = KeyAuthorization,
|
|
303
|
+
authorization extends KeyAuthorization | Input | Rpc = KeyAuthorization,
|
|
295
304
|
signature extends SignatureEnvelope.from.Value | undefined =
|
|
296
305
|
| SignatureEnvelope.from.Value
|
|
297
306
|
| undefined,
|
|
298
307
|
> = Compute<
|
|
299
308
|
authorization extends Rpc
|
|
300
309
|
? Signed
|
|
301
|
-
:
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
310
|
+
: TempoAddress.ResolveAddresses<
|
|
311
|
+
authorization &
|
|
312
|
+
(signature extends SignatureEnvelope.from.Value
|
|
313
|
+
? { signature: SignatureEnvelope.from.ReturnValue<signature> }
|
|
314
|
+
: {})
|
|
315
|
+
>
|
|
305
316
|
>
|
|
306
317
|
|
|
307
318
|
type ErrorType = Errors.GlobalErrorType
|
package/tempo/PoolId.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as Hash from '../core/Hash.js'
|
|
2
2
|
import * as Hex from '../core/Hex.js'
|
|
3
|
+
import type * as TempoAddress from './TempoAddress.js'
|
|
3
4
|
import * as TokenId from './TokenId.js'
|
|
4
5
|
|
|
5
6
|
/**
|
|
@@ -35,8 +36,8 @@ export function from(value: from.Value): Hex.Hex {
|
|
|
35
36
|
export declare namespace from {
|
|
36
37
|
export type Value = {
|
|
37
38
|
/** User token. */
|
|
38
|
-
userToken: TokenId.TokenIdOrAddress
|
|
39
|
+
userToken: TokenId.TokenIdOrAddress<TempoAddress.Address>
|
|
39
40
|
/** Validator token. */
|
|
40
|
-
validatorToken: TokenId.TokenIdOrAddress
|
|
41
|
+
validatorToken: TokenId.TokenIdOrAddress<TempoAddress.Address>
|
|
41
42
|
}
|
|
42
43
|
}
|
package/tempo/TempoAddress.ts
CHANGED
|
@@ -9,6 +9,15 @@ export type Address = core_Address.Address | Tempo
|
|
|
9
9
|
/** Root type for a Tempo Address. */
|
|
10
10
|
export type Tempo = Compute<`tempox${string}`>
|
|
11
11
|
|
|
12
|
+
/** Deeply converts all {@link ox#TempoAddress.Tempo} types to {@link ox#Address.Address}. */
|
|
13
|
+
export type ResolveAddresses<type> = type extends Tempo
|
|
14
|
+
? core_Address.Address
|
|
15
|
+
: type extends readonly (infer item)[]
|
|
16
|
+
? readonly ResolveAddresses<item>[]
|
|
17
|
+
: type extends object
|
|
18
|
+
? { [key in keyof type]: ResolveAddresses<type[key]> }
|
|
19
|
+
: type
|
|
20
|
+
|
|
12
21
|
/**
|
|
13
22
|
* Resolves an address input (either an Ethereum hex address or a Tempo address)
|
|
14
23
|
* to an Ethereum hex address.
|
package/tempo/TokenId.ts
CHANGED
|
@@ -7,7 +7,9 @@ import * as TempoAddress from './TempoAddress.js'
|
|
|
7
7
|
const tip20Prefix = '0x20c0'
|
|
8
8
|
|
|
9
9
|
export type TokenId = bigint
|
|
10
|
-
export type TokenIdOrAddress =
|
|
10
|
+
export type TokenIdOrAddress<addressType = Address.Address> =
|
|
11
|
+
| TokenId
|
|
12
|
+
| addressType
|
|
11
13
|
|
|
12
14
|
/**
|
|
13
15
|
* Converts a token ID or address to a token ID.
|
|
@@ -73,7 +75,9 @@ export function fromAddress(address: TempoAddress.Address): TokenId {
|
|
|
73
75
|
* @param tokenId - The token ID.
|
|
74
76
|
* @returns The address.
|
|
75
77
|
*/
|
|
76
|
-
export function toAddress(
|
|
78
|
+
export function toAddress(
|
|
79
|
+
tokenId: TokenIdOrAddress<TempoAddress.Address>,
|
|
80
|
+
): Address.Address {
|
|
77
81
|
if (typeof tokenId === 'string') {
|
|
78
82
|
const resolved = TempoAddress.resolve(tokenId as TempoAddress.Address)
|
|
79
83
|
Address.assert(resolved)
|
|
@@ -35,7 +35,7 @@ export type TransactionRequest<
|
|
|
35
35
|
keyAuthorization?: KeyAuthorization.KeyAuthorization<true> | undefined
|
|
36
36
|
keyData?: Hex.Hex | undefined
|
|
37
37
|
keyType?: KeyType | undefined
|
|
38
|
-
feeToken?: TokenId.TokenIdOrAddress | undefined
|
|
38
|
+
feeToken?: TokenId.TokenIdOrAddress<TempoAddress.Address> | undefined
|
|
39
39
|
nonceKey?: 'random' | bigintType | undefined
|
|
40
40
|
validBefore?: numberType | undefined
|
|
41
41
|
validAfter?: numberType | undefined
|
package/tempo/TxEnvelopeTempo.ts
CHANGED
|
@@ -69,6 +69,7 @@ export type TxEnvelopeTempo<
|
|
|
69
69
|
bigintType = bigint,
|
|
70
70
|
numberType = number,
|
|
71
71
|
type extends string = Type,
|
|
72
|
+
addressType = Address.Address,
|
|
72
73
|
> = Compute<
|
|
73
74
|
{
|
|
74
75
|
/** EIP-2930 Access List. */
|
|
@@ -78,11 +79,11 @@ export type TxEnvelopeTempo<
|
|
|
78
79
|
| AuthorizationTempo.ListSigned<bigintType, numberType>
|
|
79
80
|
| undefined
|
|
80
81
|
/** Array of calls to execute. */
|
|
81
|
-
calls: readonly Call<bigintType,
|
|
82
|
+
calls: readonly Call<bigintType, addressType>[]
|
|
82
83
|
/** EIP-155 Chain ID. */
|
|
83
84
|
chainId: numberType
|
|
84
85
|
/** Sender of the transaction. */
|
|
85
|
-
from?:
|
|
86
|
+
from?: addressType | undefined
|
|
86
87
|
/** Gas provided for transaction execution */
|
|
87
88
|
gas?: bigintType | undefined
|
|
88
89
|
/** Fee payer signature. */
|
|
@@ -100,7 +101,7 @@ export type TxEnvelopeTempo<
|
|
|
100
101
|
* The authorization must be signed with the root key, the tx can be signed by the Keychain signature.
|
|
101
102
|
*/
|
|
102
103
|
keyAuthorization?:
|
|
103
|
-
| KeyAuthorization.Signed<bigintType, numberType>
|
|
104
|
+
| KeyAuthorization.Signed<bigintType, numberType, addressType>
|
|
104
105
|
| undefined
|
|
105
106
|
/** Total fee per gas in wei (gasPrice/baseFeePerGas + maxPriorityFeePerGas). */
|
|
106
107
|
maxFeePerGas?: bigintType | undefined
|
|
@@ -127,6 +128,15 @@ export type TxEnvelopeTempo<
|
|
|
127
128
|
})
|
|
128
129
|
>
|
|
129
130
|
|
|
131
|
+
/** Input type that accepts TempoAddress for `calls.to`, `from`, etc. */
|
|
132
|
+
export type Input = TxEnvelopeTempo<
|
|
133
|
+
boolean,
|
|
134
|
+
bigint,
|
|
135
|
+
number,
|
|
136
|
+
Type,
|
|
137
|
+
TempoAddress.Address
|
|
138
|
+
>
|
|
139
|
+
|
|
130
140
|
export type Rpc<signed extends boolean = boolean> = TxEnvelopeTempo<
|
|
131
141
|
signed,
|
|
132
142
|
Hex.Hex,
|
|
@@ -486,10 +496,10 @@ export declare namespace deserialize {
|
|
|
486
496
|
* @returns A Tempo Transaction Envelope.
|
|
487
497
|
*/
|
|
488
498
|
export function from<
|
|
489
|
-
const envelope extends UnionPartialBy<
|
|
499
|
+
const envelope extends UnionPartialBy<Input, 'type'> | Serialized,
|
|
490
500
|
const signature extends SignatureEnvelope.from.Value | undefined = undefined,
|
|
491
501
|
>(
|
|
492
|
-
envelope: envelope | UnionPartialBy<
|
|
502
|
+
envelope: envelope | UnionPartialBy<Input, 'type'> | Serialized,
|
|
493
503
|
options: from.Options<signature> = {},
|
|
494
504
|
): from.ReturnValue<envelope, signature> {
|
|
495
505
|
const { feePayerSignature, signature } = options
|
|
@@ -532,20 +542,22 @@ export declare namespace from {
|
|
|
532
542
|
}
|
|
533
543
|
|
|
534
544
|
type ReturnValue<
|
|
535
|
-
envelope extends UnionPartialBy<
|
|
545
|
+
envelope extends UnionPartialBy<Input, 'type'> | Hex.Hex =
|
|
536
546
|
| TxEnvelopeTempo
|
|
537
547
|
| Hex.Hex,
|
|
538
548
|
signature extends SignatureEnvelope.from.Value | undefined = undefined,
|
|
539
549
|
> = Compute<
|
|
540
550
|
envelope extends Hex.Hex
|
|
541
551
|
? TxEnvelopeTempo
|
|
542
|
-
:
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
552
|
+
: TempoAddress.ResolveAddresses<
|
|
553
|
+
Assign<
|
|
554
|
+
envelope,
|
|
555
|
+
(signature extends SignatureEnvelope.from.Value
|
|
556
|
+
? { signature: SignatureEnvelope.from.ReturnValue<signature> }
|
|
557
|
+
: {}) & {
|
|
558
|
+
readonly type: 'tempo'
|
|
559
|
+
}
|
|
560
|
+
>
|
|
549
561
|
>
|
|
550
562
|
>
|
|
551
563
|
|
package/version.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/** @internal */
|
|
2
|
-
export const version = '0.14.
|
|
2
|
+
export const version = '0.14.7'
|
|
@@ -408,7 +408,14 @@ export function serializeResponse(response: Response): Response<true> {
|
|
|
408
408
|
|
|
409
409
|
const rawResponse = {} as Record<string, string>
|
|
410
410
|
for (const key of responseKeys) {
|
|
411
|
-
const
|
|
411
|
+
const r = raw.response as unknown as Record<string, unknown>
|
|
412
|
+
let value = r[key]
|
|
413
|
+
if (!(value instanceof ArrayBuffer)) {
|
|
414
|
+
const getter =
|
|
415
|
+
`get${key[0]!.toUpperCase()}${key.slice(1)}` as keyof typeof r
|
|
416
|
+
const fn = r[getter]
|
|
417
|
+
if (typeof fn === 'function') value = fn.call(r)
|
|
418
|
+
}
|
|
412
419
|
if (value instanceof ArrayBuffer)
|
|
413
420
|
rawResponse[key] = Base64.fromBytes(
|
|
414
421
|
new Uint8Array(value),
|
package/webauthn/Credential.ts
CHANGED
|
@@ -53,7 +53,17 @@ export function serialize(credential: Credential): Credential<true> {
|
|
|
53
53
|
|
|
54
54
|
const response = {} as Record<string, string>
|
|
55
55
|
for (const key of responseKeys) {
|
|
56
|
-
const
|
|
56
|
+
const r = raw.response as unknown as Record<string, unknown>
|
|
57
|
+
let value = r[key]
|
|
58
|
+
// Some properties (e.g. `authenticatorData`) are only accessible via
|
|
59
|
+
// getter methods (e.g. `getAuthenticatorData()`) in certain browsers
|
|
60
|
+
// and passkey providers.
|
|
61
|
+
if (!(value instanceof ArrayBuffer)) {
|
|
62
|
+
const getter =
|
|
63
|
+
`get${key[0]!.toUpperCase()}${key.slice(1)}` as keyof typeof r
|
|
64
|
+
const fn = r[getter]
|
|
65
|
+
if (typeof fn === 'function') value = fn.call(r)
|
|
66
|
+
}
|
|
57
67
|
if (value instanceof ArrayBuffer)
|
|
58
68
|
response[key] = Base64.fromBytes(new Uint8Array(value), base64UrlOptions)
|
|
59
69
|
}
|
package/webauthn/Registration.ts
CHANGED
|
@@ -302,9 +302,14 @@ export function serializeResponse(response: Response): Response<true> {
|
|
|
302
302
|
|
|
303
303
|
const rawResponse = {} as Record<string, string>
|
|
304
304
|
for (const key of responseKeys) {
|
|
305
|
-
const
|
|
306
|
-
|
|
307
|
-
)
|
|
305
|
+
const r = credential.raw.response as unknown as Record<string, unknown>
|
|
306
|
+
let value = r[key]
|
|
307
|
+
if (!(value instanceof ArrayBuffer)) {
|
|
308
|
+
const getter =
|
|
309
|
+
`get${key[0]!.toUpperCase()}${key.slice(1)}` as keyof typeof r
|
|
310
|
+
const fn = r[getter]
|
|
311
|
+
if (typeof fn === 'function') value = fn.call(r)
|
|
312
|
+
}
|
|
308
313
|
if (value instanceof ArrayBuffer)
|
|
309
314
|
rawResponse[key] = Base64.fromBytes(
|
|
310
315
|
new Uint8Array(value),
|