ox 0.14.1 → 0.14.3
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/core/internal/webauthn.js +2 -2
- package/_cjs/core/internal/webauthn.js.map +1 -1
- package/_cjs/tempo/TempoAddress.js +9 -84
- package/_cjs/tempo/TempoAddress.js.map +1 -1
- package/_cjs/tempo/index.js.map +1 -1
- package/_cjs/version.js +1 -1
- package/_cjs/webauthn/Authentication.js +9 -5
- package/_cjs/webauthn/Authentication.js.map +1 -1
- package/_cjs/webauthn/Registration.js +8 -5
- package/_cjs/webauthn/Registration.js.map +1 -1
- package/_esm/core/internal/webauthn.js +5 -2
- package/_esm/core/internal/webauthn.js.map +1 -1
- package/_esm/tempo/AuthorizationTempo.js +17 -17
- package/_esm/tempo/TempoAddress.js +18 -118
- package/_esm/tempo/TempoAddress.js.map +1 -1
- package/_esm/tempo/TxEnvelopeTempo.js +12 -12
- package/_esm/tempo/index.js +12 -14
- package/_esm/tempo/index.js.map +1 -1
- package/_esm/version.js +1 -1
- package/_esm/webauthn/Authentication.js +12 -5
- package/_esm/webauthn/Authentication.js.map +1 -1
- package/_esm/webauthn/Registration.js +11 -5
- package/_esm/webauthn/Registration.js.map +1 -1
- package/_types/core/internal/webauthn.d.ts +4 -1
- package/_types/core/internal/webauthn.d.ts.map +1 -1
- package/_types/tempo/AuthorizationTempo.d.ts +17 -17
- package/_types/tempo/TempoAddress.d.ts +14 -69
- package/_types/tempo/TempoAddress.d.ts.map +1 -1
- package/_types/tempo/TxEnvelopeTempo.d.ts +12 -12
- package/_types/tempo/index.d.ts +12 -14
- package/_types/tempo/index.d.ts.map +1 -1
- package/_types/version.d.ts +1 -1
- package/_types/webauthn/Authentication.d.ts.map +1 -1
- package/_types/webauthn/Registration.d.ts.map +1 -1
- package/core/internal/webauthn.ts +4 -1
- package/package.json +1 -1
- package/tempo/AuthorizationTempo.test.ts +1 -1
- package/tempo/AuthorizationTempo.ts +17 -17
- package/tempo/KeyAuthorization.test.ts +2 -2
- package/tempo/PoolId.test.ts +2 -2
- package/tempo/TempoAddress.test.ts +22 -191
- package/tempo/TempoAddress.ts +21 -139
- package/tempo/TokenId.test.ts +3 -3
- package/tempo/TxEnvelopeTempo.test.ts +4 -4
- package/tempo/TxEnvelopeTempo.ts +12 -12
- package/tempo/index.ts +12 -14
- package/version.ts +1 -1
- package/webauthn/Authentication.ts +14 -11
- package/webauthn/Registration.ts +17 -7
package/tempo/TokenId.test.ts
CHANGED
|
@@ -25,7 +25,7 @@ test('fromAddress', () => {
|
|
|
25
25
|
).toBe(0xdefn)
|
|
26
26
|
|
|
27
27
|
// tempo address input
|
|
28
|
-
const tempoAddr = '
|
|
28
|
+
const tempoAddr = 'tempox0x20c0000000000000000000000000000000000001'
|
|
29
29
|
expect(TokenId.fromAddress(tempoAddr)).toBe(1n)
|
|
30
30
|
})
|
|
31
31
|
|
|
@@ -44,7 +44,7 @@ test('toAddress', () => {
|
|
|
44
44
|
)
|
|
45
45
|
|
|
46
46
|
// tempo address input
|
|
47
|
-
const tempoAddr = '
|
|
47
|
+
const tempoAddr = 'tempox0x20c0000000000000000000000000000000000001'
|
|
48
48
|
expect(TokenId.toAddress(tempoAddr)).toBe(
|
|
49
49
|
'0x20C0000000000000000000000000000000000001',
|
|
50
50
|
)
|
|
@@ -88,6 +88,6 @@ test('compute', () => {
|
|
|
88
88
|
expect(address3).not.toBe(address1)
|
|
89
89
|
|
|
90
90
|
// tempo address input produces same result
|
|
91
|
-
const tempoSender = '
|
|
91
|
+
const tempoSender = 'tempox0x1234567890123456789012345678901234567890'
|
|
92
92
|
expect(TokenId.compute({ sender: tempoSender, salt: salt1 })).toBe(id1)
|
|
93
93
|
})
|
|
@@ -694,7 +694,7 @@ describe('from', () => {
|
|
|
694
694
|
|
|
695
695
|
test('tempo address input for calls.to', () => {
|
|
696
696
|
const hexAddr = '0x70997970c51812dc3a010c7d01b50e0d17dc79c8'
|
|
697
|
-
const tempoAddr = '
|
|
697
|
+
const tempoAddr = 'tempox0x70997970c51812dc3a010c7d01b50e0d17dc79c8'
|
|
698
698
|
|
|
699
699
|
const envelope = TxEnvelopeTempo.from({
|
|
700
700
|
chainId: 1,
|
|
@@ -707,7 +707,7 @@ describe('from', () => {
|
|
|
707
707
|
|
|
708
708
|
test('tempo address input for from', () => {
|
|
709
709
|
const hexAddr = '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266'
|
|
710
|
-
const tempoAddr = '
|
|
710
|
+
const tempoAddr = 'tempox0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266'
|
|
711
711
|
|
|
712
712
|
const envelope = TxEnvelopeTempo.from({
|
|
713
713
|
chainId: 1,
|
|
@@ -1411,7 +1411,7 @@ describe('getSignPayload', () => {
|
|
|
1411
1411
|
|
|
1412
1412
|
test('tempo address input for from', () => {
|
|
1413
1413
|
const hexAddr = '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266'
|
|
1414
|
-
const tempoAddr = '
|
|
1414
|
+
const tempoAddr = 'tempox0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266'
|
|
1415
1415
|
|
|
1416
1416
|
const transaction = TxEnvelopeTempo.from({
|
|
1417
1417
|
chainId: 1,
|
|
@@ -1455,7 +1455,7 @@ describe('getFeePayerSignPayload', () => {
|
|
|
1455
1455
|
|
|
1456
1456
|
test('tempo address input for sender', () => {
|
|
1457
1457
|
const hexAddr = '0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266'
|
|
1458
|
-
const tempoAddr = '
|
|
1458
|
+
const tempoAddr = 'tempox0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266'
|
|
1459
1459
|
|
|
1460
1460
|
const transaction = TxEnvelopeTempo.from({
|
|
1461
1461
|
chainId: 1,
|
package/tempo/TxEnvelopeTempo.ts
CHANGED
|
@@ -155,7 +155,7 @@ export type Type = typeof type
|
|
|
155
155
|
* import { TxEnvelopeTempo } from 'ox/tempo'
|
|
156
156
|
*
|
|
157
157
|
* TxEnvelopeTempo.assert({
|
|
158
|
-
* calls: [{ to: '
|
|
158
|
+
* calls: [{ to: 'tempox0x0000000000000000000000000000000000000000', value: 0n }],
|
|
159
159
|
* chainId: 1,
|
|
160
160
|
* maxFeePerGas: 1000000000n,
|
|
161
161
|
* })
|
|
@@ -414,7 +414,7 @@ export declare namespace deserialize {
|
|
|
414
414
|
* chainId: 1, // [!code focus]
|
|
415
415
|
* calls: [{ // [!code focus]
|
|
416
416
|
* data: '0xdeadbeef', // [!code focus]
|
|
417
|
-
* to: '
|
|
417
|
+
* to: 'tempox0x0000000000000000000000000000000000000000', // [!code focus]
|
|
418
418
|
* }], // [!code focus]
|
|
419
419
|
* maxFeePerGas: Value.fromGwei('10'), // [!code focus]
|
|
420
420
|
* maxPriorityFeePerGas: Value.fromGwei('1'), // [!code focus]
|
|
@@ -435,7 +435,7 @@ export declare namespace deserialize {
|
|
|
435
435
|
* chainId: 1,
|
|
436
436
|
* calls: [{
|
|
437
437
|
* data: '0xdeadbeef',
|
|
438
|
-
* to: '
|
|
438
|
+
* to: 'tempox0x0000000000000000000000000000000000000000',
|
|
439
439
|
* }],
|
|
440
440
|
* maxFeePerGas: Value.fromGwei('10'),
|
|
441
441
|
* maxPriorityFeePerGas: Value.fromGwei('1'),
|
|
@@ -573,7 +573,7 @@ export declare namespace from {
|
|
|
573
573
|
* chainId: 1,
|
|
574
574
|
* calls: [{
|
|
575
575
|
* data: '0xdeadbeef',
|
|
576
|
-
* to: '
|
|
576
|
+
* to: 'tempox0x0000000000000000000000000000000000000000',
|
|
577
577
|
* }],
|
|
578
578
|
* maxFeePerGas: Value.fromGwei('10'),
|
|
579
579
|
* })
|
|
@@ -595,7 +595,7 @@ export declare namespace from {
|
|
|
595
595
|
* chainId: 1,
|
|
596
596
|
* calls: [{
|
|
597
597
|
* data: '0xdeadbeef',
|
|
598
|
-
* to: '
|
|
598
|
+
* to: 'tempox0x0000000000000000000000000000000000000000',
|
|
599
599
|
* }],
|
|
600
600
|
* maxFeePerGas: Value.fromGwei('10'),
|
|
601
601
|
* })
|
|
@@ -780,7 +780,7 @@ export declare namespace serialize {
|
|
|
780
780
|
* chainId: 1,
|
|
781
781
|
* calls: [{
|
|
782
782
|
* data: '0xdeadbeef',
|
|
783
|
-
* to: '
|
|
783
|
+
* to: 'tempox0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
|
|
784
784
|
* }],
|
|
785
785
|
* nonce: 0n,
|
|
786
786
|
* maxFeePerGas: 1000000000n,
|
|
@@ -810,7 +810,7 @@ export declare namespace serialize {
|
|
|
810
810
|
* chainId: 1,
|
|
811
811
|
* calls: [{
|
|
812
812
|
* data: '0xdeadbeef',
|
|
813
|
-
* to: '
|
|
813
|
+
* to: 'tempox0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
|
|
814
814
|
* }],
|
|
815
815
|
* nonce: 0n,
|
|
816
816
|
* maxFeePerGas: 1000000000n,
|
|
@@ -874,7 +874,7 @@ export declare namespace getSignPayload {
|
|
|
874
874
|
* chainId: 1,
|
|
875
875
|
* calls: [{
|
|
876
876
|
* data: '0xdeadbeef',
|
|
877
|
-
* to: '
|
|
877
|
+
* to: 'tempox0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
|
|
878
878
|
* }],
|
|
879
879
|
* nonce: 0n,
|
|
880
880
|
* maxFeePerGas: 1000000000n,
|
|
@@ -948,7 +948,7 @@ export declare namespace hash {
|
|
|
948
948
|
* chainId: 1,
|
|
949
949
|
* calls: [{
|
|
950
950
|
* data: '0xdeadbeef',
|
|
951
|
-
* to: '
|
|
951
|
+
* to: 'tempox0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
|
|
952
952
|
* }],
|
|
953
953
|
* nonce: 0n,
|
|
954
954
|
* maxFeePerGas: 1000000000n,
|
|
@@ -956,7 +956,7 @@ export declare namespace hash {
|
|
|
956
956
|
* })
|
|
957
957
|
*
|
|
958
958
|
* const payload = TxEnvelopeTempo.getFeePayerSignPayload(envelope, {
|
|
959
|
-
* sender: '
|
|
959
|
+
* sender: 'tempox0xd8da6bf26964af9d7eed9e03e53415d37aa96045'
|
|
960
960
|
* }) // [!code focus]
|
|
961
961
|
* // @log: '0x...'
|
|
962
962
|
*
|
|
@@ -1005,7 +1005,7 @@ export declare namespace getFeePayerSignPayload {
|
|
|
1005
1005
|
* const valid = TxEnvelopeTempo.validate({
|
|
1006
1006
|
* calls: [{
|
|
1007
1007
|
* data: '0xdeadbeef',
|
|
1008
|
-
* to: '
|
|
1008
|
+
* to: 'tempox0x0000000000000000000000000000000000000000',
|
|
1009
1009
|
* }],
|
|
1010
1010
|
* chainId: 1,
|
|
1011
1011
|
* maxFeePerGas: 1000000000n,
|
|
@@ -1057,7 +1057,7 @@ export class CallsEmptyError extends Errors.BaseError {
|
|
|
1057
1057
|
* import { TxEnvelopeTempo } from 'ox/tempo'
|
|
1058
1058
|
*
|
|
1059
1059
|
* TxEnvelopeTempo.assert({
|
|
1060
|
-
* calls: [{ to: '
|
|
1060
|
+
* calls: [{ to: 'tempox0x0000000000000000000000000000000000000000' }],
|
|
1061
1061
|
* chainId: 1,
|
|
1062
1062
|
* validBefore: 100,
|
|
1063
1063
|
* validAfter: 200,
|
package/tempo/index.ts
CHANGED
|
@@ -17,7 +17,7 @@ export type {}
|
|
|
17
17
|
* import { AuthorizationTempo } from 'ox/tempo'
|
|
18
18
|
*
|
|
19
19
|
* const authorization = AuthorizationTempo.from({
|
|
20
|
-
* address: '
|
|
20
|
+
* address: 'tempox0xbe95c3f554e9fc85ec51be69a3d807a0d55bcf2c',
|
|
21
21
|
* chainId: 1,
|
|
22
22
|
* nonce: 40n,
|
|
23
23
|
* })
|
|
@@ -59,7 +59,7 @@ export * as AuthorizationTempo from './AuthorizationTempo.js'
|
|
|
59
59
|
* expiry: 1234567890,
|
|
60
60
|
* type: 'p256',
|
|
61
61
|
* limits: [{
|
|
62
|
-
* token: '
|
|
62
|
+
* token: 'tempox0x20c0000000000000000000000000000000000001',
|
|
63
63
|
* limit: Value.from('10', 6),
|
|
64
64
|
* }],
|
|
65
65
|
* })
|
|
@@ -125,19 +125,17 @@ export * as SignatureEnvelope from './SignatureEnvelope.js'
|
|
|
125
125
|
/**
|
|
126
126
|
* Tempo address encoding/decoding utilities for human-readable addresses.
|
|
127
127
|
*
|
|
128
|
-
* Tempo addresses use a
|
|
129
|
-
* and `tempoz1` prefix for zone addresses. Includes CompactSize zone ID encoding
|
|
130
|
-
* and double-SHA256 checksumming.
|
|
128
|
+
* Tempo addresses use a simple `tempox` prefix before the hex address.
|
|
131
129
|
*
|
|
132
130
|
* @example
|
|
133
131
|
* ```ts twoslash
|
|
134
132
|
* import { TempoAddress } from 'ox/tempo'
|
|
135
133
|
*
|
|
136
134
|
* const encoded = TempoAddress.format('0x742d35Cc6634C0532925a3b844Bc9e7595f2bD28')
|
|
137
|
-
* // @log: '
|
|
135
|
+
* // @log: 'tempox0x742d35cc6634c0532925a3b844bc9e7595f2bd28'
|
|
138
136
|
*
|
|
139
|
-
* const { address
|
|
140
|
-
* // @log: { address: '0x742d35CC6634c0532925a3B844bc9e7595F2Bd28'
|
|
137
|
+
* const { address } = TempoAddress.parse(encoded)
|
|
138
|
+
* // @log: { address: '0x742d35CC6634c0532925a3B844bc9e7595F2Bd28' }
|
|
141
139
|
* ```
|
|
142
140
|
*
|
|
143
141
|
* @category Reference
|
|
@@ -180,7 +178,7 @@ export * as Tick from './Tick.js'
|
|
|
180
178
|
*
|
|
181
179
|
* const tokenId = TokenId.from(1n)
|
|
182
180
|
* const address = TokenId.toAddress(1n)
|
|
183
|
-
* // '
|
|
181
|
+
* // 'tempox0x20c0000000000000000000000000000000000001'
|
|
184
182
|
* ```
|
|
185
183
|
*
|
|
186
184
|
* @category Reference
|
|
@@ -232,7 +230,7 @@ export * as TokenRole from './TokenRole.js'
|
|
|
232
230
|
* value: '0x9b6e64a8ec60000',
|
|
233
231
|
* },
|
|
234
232
|
* ],
|
|
235
|
-
* feeToken: '
|
|
233
|
+
* feeToken: 'tempox0x20c0000000000000000000000000000000000000',
|
|
236
234
|
* transactionIndex: '0x2',
|
|
237
235
|
* from: '0x814e5e0e31016b9a7f138c76b7e7b2bb5c1ab6a6',
|
|
238
236
|
* value: '0x9b6e64a8ec60000',
|
|
@@ -271,7 +269,7 @@ export * as Transaction from './Transaction.js'
|
|
|
271
269
|
* const receipt = TransactionReceipt.fromRpc({
|
|
272
270
|
* status: '0x1',
|
|
273
271
|
* feePayer: '0x...',
|
|
274
|
-
* feeToken: '
|
|
272
|
+
* feeToken: 'tempox0x20c0000000000000000000000000000000000001',
|
|
275
273
|
* // ... other fields
|
|
276
274
|
* } as any)
|
|
277
275
|
* ```
|
|
@@ -292,8 +290,8 @@ export * as TransactionReceipt from './TransactionReceipt.js'
|
|
|
292
290
|
* import { TransactionRequest } from 'ox/tempo'
|
|
293
291
|
*
|
|
294
292
|
* const request = TransactionRequest.toRpc({
|
|
295
|
-
* calls: [{ to: '
|
|
296
|
-
* feeToken: '
|
|
293
|
+
* calls: [{ to: 'tempox0xcafebabecafebabecafebabecafebabecafebabe', data: '0xdeadbeef' }],
|
|
294
|
+
* feeToken: 'tempox0x20c0000000000000000000000000000000000000',
|
|
297
295
|
* })
|
|
298
296
|
* ```
|
|
299
297
|
*
|
|
@@ -315,7 +313,7 @@ export * as TransactionRequest from './TransactionRequest.js'
|
|
|
315
313
|
*
|
|
316
314
|
* const envelope = TxEnvelopeTempo.from({
|
|
317
315
|
* chainId: 1,
|
|
318
|
-
* calls: [{ to: '
|
|
316
|
+
* calls: [{ to: 'tempox0x0000000000000000000000000000000000000000', data: '0xdeadbeef' }],
|
|
319
317
|
* maxFeePerGas: Value.fromGwei('10'),
|
|
320
318
|
* })
|
|
321
319
|
*
|
package/version.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/** @internal */
|
|
2
|
-
export const version = '0.14.
|
|
2
|
+
export const version = '0.14.3'
|
|
@@ -471,7 +471,8 @@ export declare namespace serializeResponse {
|
|
|
471
471
|
*/
|
|
472
472
|
export async function sign(options: sign.Options): Promise<sign.ReturnType> {
|
|
473
473
|
const {
|
|
474
|
-
getFn =
|
|
474
|
+
getFn = (opts: Types.CredentialRequestOptions | undefined) =>
|
|
475
|
+
window.navigator.credentials.get(opts),
|
|
475
476
|
...rest
|
|
476
477
|
} = options
|
|
477
478
|
const requestOptions =
|
|
@@ -485,22 +486,24 @@ export async function sign(options: sign.Options): Promise<sign.ReturnType> {
|
|
|
485
486
|
if (!credential) throw new SignFailedError()
|
|
486
487
|
const response = credential.response as AuthenticatorAssertionResponse
|
|
487
488
|
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
489
|
+
// Eagerly copy ArrayBuffer data to avoid cross-origin access errors
|
|
490
|
+
// when browser extensions (e.g. 1Password on Firefox) replace
|
|
491
|
+
// `navigator.credentials` with a cross-compartment proxy.
|
|
492
|
+
const clientDataJSONBytes = new Uint8Array(response.clientDataJSON)
|
|
493
|
+
const authenticatorDataBytes = new Uint8Array(response.authenticatorData)
|
|
494
|
+
const signatureBytes = new Uint8Array(response.signature)
|
|
495
|
+
const id = credential.id
|
|
496
|
+
|
|
497
|
+
const clientDataJSON = String.fromCharCode(...clientDataJSONBytes)
|
|
491
498
|
const challengeIndex = clientDataJSON.indexOf('"challenge"')
|
|
492
499
|
const typeIndex = clientDataJSON.indexOf('"type"')
|
|
493
500
|
|
|
494
|
-
const signature = internal.parseAsn1Signature(
|
|
495
|
-
new Uint8Array(response.signature),
|
|
496
|
-
)
|
|
501
|
+
const signature = internal.parseAsn1Signature(signatureBytes)
|
|
497
502
|
|
|
498
503
|
return {
|
|
499
|
-
id
|
|
504
|
+
id,
|
|
500
505
|
metadata: {
|
|
501
|
-
authenticatorData: Hex.fromBytes(
|
|
502
|
-
new Uint8Array(response.authenticatorData),
|
|
503
|
-
),
|
|
506
|
+
authenticatorData: Hex.fromBytes(authenticatorDataBytes),
|
|
504
507
|
clientDataJSON,
|
|
505
508
|
challengeIndex,
|
|
506
509
|
typeIndex,
|
package/webauthn/Registration.ts
CHANGED
|
@@ -56,9 +56,8 @@ export async function create(
|
|
|
56
56
|
options: create.Options,
|
|
57
57
|
): Promise<Credential_.Credential> {
|
|
58
58
|
const {
|
|
59
|
-
createFn =
|
|
60
|
-
window.navigator.credentials,
|
|
61
|
-
),
|
|
59
|
+
createFn = (opts: Types.CredentialCreationOptions | undefined) =>
|
|
60
|
+
window.navigator.credentials.create(opts),
|
|
62
61
|
...rest
|
|
63
62
|
} = options
|
|
64
63
|
const creationOptions =
|
|
@@ -73,12 +72,23 @@ export async function create(
|
|
|
73
72
|
|
|
74
73
|
const response =
|
|
75
74
|
credential.response as Types.AuthenticatorAttestationResponse
|
|
76
|
-
|
|
75
|
+
|
|
76
|
+
// Eagerly copy ArrayBuffer data to avoid cross-origin access errors
|
|
77
|
+
// when browser extensions (e.g. 1Password on Firefox) replace
|
|
78
|
+
// `navigator.credentials` with a cross-compartment proxy.
|
|
79
|
+
const attestationObject = response.attestationObject
|
|
80
|
+
const clientDataJSON = response.clientDataJSON
|
|
81
|
+
const id = credential.id
|
|
82
|
+
|
|
83
|
+
const publicKey = await internal.parseCredentialPublicKey(
|
|
84
|
+
response,
|
|
85
|
+
attestationObject,
|
|
86
|
+
)
|
|
77
87
|
|
|
78
88
|
return {
|
|
79
|
-
attestationObject
|
|
80
|
-
clientDataJSON
|
|
81
|
-
id
|
|
89
|
+
attestationObject,
|
|
90
|
+
clientDataJSON,
|
|
91
|
+
id,
|
|
82
92
|
publicKey,
|
|
83
93
|
raw: credential,
|
|
84
94
|
}
|