@0xsequence/wallet-primitives 3.0.0-beta.9 → 3.0.1

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.
Files changed (47) hide show
  1. package/.turbo/turbo-build.log +2 -2
  2. package/.turbo/turbo-lint.log +4 -0
  3. package/.turbo/turbo-test.log +28 -0
  4. package/.turbo/turbo-typecheck.log +4 -0
  5. package/CHANGELOG.md +91 -0
  6. package/dist/attestation.d.ts +15 -3
  7. package/dist/attestation.d.ts.map +1 -1
  8. package/dist/attestation.js +1 -1
  9. package/dist/attestation.js.map +1 -1
  10. package/dist/config.d.ts +40 -10
  11. package/dist/config.d.ts.map +1 -1
  12. package/dist/config.js +7 -7
  13. package/dist/config.js.map +1 -1
  14. package/dist/extensions/recovery.d.ts +4 -4
  15. package/dist/extensions/recovery.d.ts.map +1 -1
  16. package/dist/extensions/recovery.js +2 -2
  17. package/dist/extensions/recovery.js.map +1 -1
  18. package/dist/network.d.ts +10 -1
  19. package/dist/network.d.ts.map +1 -1
  20. package/dist/network.js +234 -9
  21. package/dist/network.js.map +1 -1
  22. package/dist/payload.d.ts.map +1 -1
  23. package/dist/payload.js.map +1 -1
  24. package/dist/signature.d.ts.map +1 -1
  25. package/dist/signature.js +8 -6
  26. package/dist/signature.js.map +1 -1
  27. package/dist/utils.d.ts.map +1 -1
  28. package/dist/utils.js +1 -1
  29. package/dist/utils.js.map +1 -1
  30. package/eslint.config.js +12 -0
  31. package/package.json +7 -5
  32. package/src/attestation.ts +16 -4
  33. package/src/config.ts +62 -20
  34. package/src/extensions/recovery.ts +7 -8
  35. package/src/network.ts +248 -10
  36. package/src/payload.ts +1 -1
  37. package/src/signature.ts +10 -8
  38. package/src/utils.ts +2 -2
  39. package/test/address.test.ts +9 -9
  40. package/test/attestation.test.ts +1 -1
  41. package/test/config.test.ts +1 -1
  42. package/test/passkeys.test.ts +3 -10
  43. package/test/payload.test.ts +2 -7
  44. package/test/precondition.test.ts +6 -8
  45. package/test/signature.test.ts +11 -17
  46. package/test/utils.test.ts +4 -4
  47. package/eslint.config.mjs +0 -4
@@ -88,7 +88,7 @@ describe('Address', () => {
88
88
  })
89
89
 
90
90
  it('should work with Dev1 context', () => {
91
- const { stage2, ...dev1Context } = Dev1
91
+ const { stage2: _, ...dev1Context } = Dev1
92
92
  const address = from(sampleConfig, dev1Context)
93
93
 
94
94
  expect(() => Address.assert(address)).not.toThrow()
@@ -96,53 +96,53 @@ describe('Address', () => {
96
96
  })
97
97
 
98
98
  it('should work with Dev2 context', () => {
99
- const { stage2, ...dev2Context } = Dev2
99
+ const { stage2: _stage2_1, ...dev2Context } = Dev2
100
100
  const address = from(sampleConfig, dev2Context)
101
101
 
102
102
  expect(() => Address.assert(address)).not.toThrow()
103
103
  expect(address).toMatch(/^0x[a-fA-F0-9]{40}$/)
104
104
 
105
105
  // Should be different from Dev1
106
- const { stage2: _, ...dev1Context } = Dev1
106
+ const { stage2: _stage2_2, ...dev1Context } = Dev1
107
107
  const dev1Address = from(sampleConfig, dev1Context)
108
108
  expect(address).not.toBe(dev1Address)
109
109
  })
110
110
 
111
111
  it('should work with Rc3 context', () => {
112
- const { stage2, ...rc3Context } = Rc3
112
+ const { stage2: _stage2_1, ...rc3Context } = Rc3
113
113
  const address = from(sampleConfig, rc3Context)
114
114
 
115
115
  expect(() => Address.assert(address)).not.toThrow()
116
116
  expect(address).toMatch(/^0x[a-fA-F0-9]{40}$/)
117
117
 
118
118
  // Should be different from Dev2
119
- const { stage2: _, ...dev2Context } = Dev2
119
+ const { stage2: _stage2_2, ...dev2Context } = Dev2
120
120
  const dev2Address = from(sampleConfig, dev2Context)
121
121
  expect(address).not.toBe(dev2Address)
122
122
  })
123
123
 
124
124
  it('should work with Rc4 context', () => {
125
- const { stage2, ...rc4Context } = Rc4
125
+ const { stage2: _stage2_1, ...rc4Context } = Rc4
126
126
  const address = from(sampleConfig, rc4Context)
127
127
 
128
128
  expect(() => Address.assert(address)).not.toThrow()
129
129
  expect(address).toMatch(/^0x[a-fA-F0-9]{40}$/)
130
130
 
131
131
  // Should be different from Dev2
132
- const { stage2: _, ...dev2Context } = Dev2
132
+ const { stage2: _stage2_2, ...dev2Context } = Dev2
133
133
  const dev2Address = from(sampleConfig, dev2Context)
134
134
  expect(address).not.toBe(dev2Address)
135
135
  })
136
136
 
137
137
  it('should work with Rc5 context', () => {
138
- const { stage2, ...rc5Context } = Rc5
138
+ const { stage2: _stage2_1, ...rc5Context } = Rc5
139
139
  const address = from(sampleConfig, rc5Context)
140
140
 
141
141
  expect(() => Address.assert(address)).not.toThrow()
142
142
  expect(address).toMatch(/^0x[a-fA-F0-9]{40}$/)
143
143
 
144
144
  // Should be different from Dev2
145
- const { stage2: _, ...dev2Context } = Dev2
145
+ const { stage2: _stage2_2, ...dev2Context } = Dev2
146
146
  const dev2Address = from(sampleConfig, dev2Context)
147
147
  expect(address).not.toBe(dev2Address)
148
148
  })
@@ -1,5 +1,5 @@
1
1
  import { describe, expect, it } from 'vitest'
2
- import { Address, Bytes, Hash, Hex } from 'ox'
2
+ import { Bytes, Hash } from 'ox'
3
3
 
4
4
  import {
5
5
  Attestation,
@@ -1,5 +1,5 @@
1
1
  import { describe, expect, it } from 'vitest'
2
- import { Address, Bytes, Hash, Hex } from 'ox'
2
+ import { Bytes } from 'ox'
3
3
 
4
4
  import {
5
5
  Config,
@@ -104,13 +104,6 @@ describe('Passkeys', () => {
104
104
  y: testPublicKeyY,
105
105
  }
106
106
 
107
- const samplePublicKeyWithHashMetadata: PublicKey = {
108
- requireUserVerification: true,
109
- x: testPublicKeyX,
110
- y: testPublicKeyY,
111
- metadata: testMetadataHash,
112
- }
113
-
114
107
  // Realistic authenticator data based on WebAuthn spec and ox patterns
115
108
  // This represents actual WebAuthn authenticator data structure
116
109
  const sampleAuthenticatorData = Bytes.fromHex(
@@ -196,7 +189,7 @@ describe('Passkeys', () => {
196
189
  { name: 'special chars', credentialId: '!@#$%^&*()_+{}|:"<>?[]\\;\',./' },
197
190
  ]
198
191
 
199
- testCases.forEach(({ name, credentialId }) => {
192
+ testCases.forEach(({ credentialId }) => {
200
193
  const metadata: PasskeyMetadata = { credentialId }
201
194
  const tree = metadataTree(metadata)
202
195
  expect(GenericTree.isLeaf(tree)).toBe(true)
@@ -709,7 +702,7 @@ describe('Passkeys', () => {
709
702
  },
710
703
  ]
711
704
 
712
- specialCharTests.forEach(({ name, credentialId, clientData }) => {
705
+ specialCharTests.forEach(({ credentialId, clientData }) => {
713
706
  if (credentialId) {
714
707
  const unicodeMetadata: PasskeyMetadata = { credentialId }
715
708
  const tree = metadataTree(unicodeMetadata)
@@ -787,7 +780,7 @@ describe('Passkeys', () => {
787
780
  { userVerification: true, metadata: true, description: 'User verification with metadata' },
788
781
  ]
789
782
 
790
- testCombinations.forEach(({ userVerification, metadata, description }) => {
783
+ testCombinations.forEach(({ userVerification, metadata }) => {
791
784
  const pubKey = createValidPublicKey({
792
785
  requireUserVerification: userVerification,
793
786
  ...(metadata && { metadata: samplePasskeyMetadata }),
@@ -1,6 +1,5 @@
1
- import { describe, expect, it, vi } from 'vitest'
2
- import { Address, Bytes, Hash, Hex } from 'ox'
3
- import { UserOperation } from 'ox/erc4337'
1
+ import { describe, expect, it } from 'vitest'
2
+ import { Address, Bytes, Hex } from 'ox'
4
3
 
5
4
  import {
6
5
  KIND_TRANSACTIONS,
@@ -17,11 +16,7 @@ import {
17
16
  Digest,
18
17
  SessionImplicitAuthorize,
19
18
  Calls4337_07,
20
- Recovery,
21
- MayRecoveryPayload,
22
- Payload,
23
19
  Parented,
24
- TypedDataToSign,
25
20
  SolidityDecoded,
26
21
  fromMessage,
27
22
  fromConfigUpdate,
@@ -1,7 +1,6 @@
1
1
  import { describe, expect, it } from 'vitest'
2
2
 
3
3
  import {
4
- Precondition,
5
4
  NativeBalancePrecondition,
6
5
  Erc20BalancePrecondition,
7
6
  Erc20ApprovalPrecondition,
@@ -10,7 +9,6 @@ import {
10
9
  Erc1155BalancePrecondition,
11
10
  Erc1155ApprovalPrecondition,
12
11
  AnyPrecondition,
13
- IntentPrecondition,
14
12
  isValidPreconditionType,
15
13
  createPrecondition,
16
14
  createIntentPrecondition,
@@ -225,13 +223,13 @@ describe('Precondition', () => {
225
223
  })
226
224
 
227
225
  it('should throw for null precondition', () => {
228
- expect(() => createPrecondition(null as any)).toThrow(
226
+ expect(() => createPrecondition(null as unknown as AnyPrecondition)).toThrow(
229
227
  "Invalid precondition object: missing or invalid 'type' property.",
230
228
  )
231
229
  })
232
230
 
233
231
  it('should throw for undefined precondition', () => {
234
- expect(() => createPrecondition(undefined as any)).toThrow(
232
+ expect(() => createPrecondition(undefined as unknown as AnyPrecondition)).toThrow(
235
233
  "Invalid precondition object: missing or invalid 'type' property.",
236
234
  )
237
235
  })
@@ -240,7 +238,7 @@ describe('Precondition', () => {
240
238
  const invalidPrecondition = {
241
239
  address: testAddress,
242
240
  min: testMinAmount,
243
- } as any
241
+ } as unknown as AnyPrecondition
244
242
  expect(() => createPrecondition(invalidPrecondition)).toThrow(
245
243
  "Invalid precondition object: missing or invalid 'type' property.",
246
244
  )
@@ -250,7 +248,7 @@ describe('Precondition', () => {
250
248
  const invalidPrecondition = {
251
249
  type: 'invalid-type',
252
250
  address: testAddress,
253
- } as any
251
+ } as unknown as AnyPrecondition
254
252
  expect(() => createPrecondition(invalidPrecondition)).toThrow(
255
253
  "Invalid precondition object: missing or invalid 'type' property.",
256
254
  )
@@ -260,7 +258,7 @@ describe('Precondition', () => {
260
258
  const invalidPrecondition = {
261
259
  type: 123,
262
260
  address: testAddress,
263
- } as any
261
+ } as unknown as AnyPrecondition
264
262
  expect(() => createPrecondition(invalidPrecondition)).toThrow(
265
263
  "Invalid precondition object: missing or invalid 'type' property.",
266
264
  )
@@ -386,7 +384,7 @@ describe('Precondition', () => {
386
384
  const invalidPrecondition = {
387
385
  type: 'invalid-type',
388
386
  address: testAddress,
389
- } as any
387
+ } as unknown as AnyPrecondition
390
388
  expect(() => createIntentPrecondition(invalidPrecondition)).toThrow('Invalid precondition type: invalid-type')
391
389
  })
392
390
 
@@ -14,7 +14,6 @@ import {
14
14
  FLAG_SIGNATURE_SAPIENT,
15
15
  FLAG_SIGNATURE_SAPIENT_COMPACT,
16
16
  RSY,
17
- SignatureOfSignerLeafEthSign,
18
17
  SignatureOfSignerLeafHash,
19
18
  SignatureOfSignerLeafErc1271,
20
19
  SignatureOfSapientSignerLeaf,
@@ -42,7 +41,7 @@ import {
42
41
  recover,
43
42
  } from '../src/signature.js'
44
43
  import { packRSY } from '../src/utils.js'
45
- import { Config, SignerLeaf, SapientSignerLeaf } from '../src/config.js'
44
+ import { SignerLeaf, SapientSignerLeaf, SubdigestLeaf, Topology, NestedLeaf } from '../src/config.js'
46
45
  import * as Payload from '../src/payload.js'
47
46
  import { ChainId } from '../src/network.js'
48
47
 
@@ -63,11 +62,6 @@ describe('Signature', () => {
63
62
  ...sampleRSY,
64
63
  }
65
64
 
66
- const sampleEthSignSignature: SignatureOfSignerLeafEthSign = {
67
- type: 'eth_sign',
68
- ...sampleRSY,
69
- }
70
-
71
65
  const sampleErc1271Signature: SignatureOfSignerLeafErc1271 = {
72
66
  type: 'erc1271',
73
67
  address: testAddress,
@@ -377,7 +371,7 @@ describe('Signature', () => {
377
371
  expect(result.nodes).toHaveLength(1)
378
372
  expect(result.leftover).toHaveLength(0)
379
373
 
380
- const node = result.nodes[0] as any
374
+ const node = result.nodes[0] as SubdigestLeaf
381
375
  expect(node.type).toBe('subdigest')
382
376
  expect(node.digest).toBe(digest)
383
377
  })
@@ -517,7 +511,7 @@ describe('Signature', () => {
517
511
  })
518
512
 
519
513
  it('should throw for invalid topology', () => {
520
- expect(() => encodeTopology({} as any)).toThrow('Invalid topology')
514
+ expect(() => encodeTopology({} as Topology)).toThrow('Invalid topology')
521
515
  })
522
516
  })
523
517
 
@@ -696,9 +690,9 @@ describe('Signature', () => {
696
690
 
697
691
  const signatureProvider = () => sampleHashSignature
698
692
 
699
- const result = fillLeaves(nestedTopology, signatureProvider)
700
- expect((result as any).type).toBe('nested')
701
- expect((result as any).tree).toHaveProperty('signature')
693
+ const result = fillLeaves(nestedTopology, signatureProvider) as NestedLeaf
694
+ expect(result.type).toBe('nested')
695
+ expect(result.tree).toHaveProperty('signature')
702
696
  })
703
697
 
704
698
  it('should handle topology without signatures', () => {
@@ -751,12 +745,12 @@ describe('Signature', () => {
751
745
 
752
746
  const result = fillLeaves(binaryTree, signatureProvider)
753
747
  expect(Array.isArray(result)).toBe(true)
754
- expect((result as any)[0]).toHaveProperty('signature')
755
- expect((result as any)[1]).toHaveProperty('signature')
748
+ expect(result[0]).toHaveProperty('signature')
749
+ expect(result[1]).toHaveProperty('signature')
756
750
  })
757
751
 
758
752
  it('should throw for invalid topology', () => {
759
- expect(() => fillLeaves({} as any, () => undefined)).toThrow('Invalid topology')
753
+ expect(() => fillLeaves({} as Topology, () => undefined)).toThrow('Invalid topology')
760
754
  })
761
755
  })
762
756
  })
@@ -917,7 +911,7 @@ describe('Signature', () => {
917
911
  },
918
912
  ]
919
913
 
920
- signatures.forEach(({ topology, name }) => {
914
+ signatures.forEach(({ topology }) => {
921
915
  const signature = {
922
916
  noChainId: false,
923
917
  configuration: {
@@ -1760,7 +1754,7 @@ describe('Signature', () => {
1760
1754
  },
1761
1755
  ]
1762
1756
 
1763
- for (const { name, payload } of payloadTypes) {
1757
+ for (const { payload } of payloadTypes) {
1764
1758
  const sapientSignature: RawSignature = {
1765
1759
  noChainId: false,
1766
1760
  configuration: {
@@ -248,7 +248,7 @@ describe('Utils', () => {
248
248
 
249
249
  it('should revive Uint8Array values', () => {
250
250
  const reviver = createJSONReviver()
251
- const result = reviver('test', { __uint8array: [1, 2, 3, 255] })
251
+ const result = reviver('test', { __uint8array: [1, 2, 3, 255] }) as Uint8Array
252
252
 
253
253
  expect(result).toBeInstanceOf(Uint8Array)
254
254
  expect(Array.from(result)).toEqual([1, 2, 3, 255])
@@ -314,7 +314,7 @@ describe('Utils', () => {
314
314
 
315
315
  it('should handle empty Uint8Array', () => {
316
316
  const reviver = createJSONReviver()
317
- const result = reviver('test', { __uint8array: [] })
317
+ const result = reviver('test', { __uint8array: [] }) as Uint8Array
318
318
 
319
319
  expect(result).toBeInstanceOf(Uint8Array)
320
320
  expect(result.length).toBe(0)
@@ -401,7 +401,7 @@ describe('Utils', () => {
401
401
 
402
402
  it('should deserialize objects with BigInt', () => {
403
403
  const json = '{"value":{"__bigint":"0x75bcd15"},"name":"test"}'
404
- const result = fromJSON(json)
404
+ const result = fromJSON(json) as { value: bigint; name: string }
405
405
 
406
406
  expect(result.value).toBe(123456789n)
407
407
  expect(result.name).toBe('test')
@@ -409,7 +409,7 @@ describe('Utils', () => {
409
409
 
410
410
  it('should deserialize objects with Uint8Array', () => {
411
411
  const json = '{"data":{"__uint8array":[1,2,3]},"name":"test"}'
412
- const result = fromJSON(json)
412
+ const result = fromJSON(json) as { data: Uint8Array; name: string }
413
413
 
414
414
  expect(result.data).toBeInstanceOf(Uint8Array)
415
415
  expect(Array.from(result.data)).toEqual([1, 2, 3])
package/eslint.config.mjs DELETED
@@ -1,4 +0,0 @@
1
- import { config as baseConfig } from "@repo/eslint-config/base"
2
-
3
- /** @type {import("eslint").Linter.Config} */
4
- export default baseConfig