@libid/contracts 0.6.0 → 0.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.
Files changed (180) hide show
  1. package/README.md +65 -26
  2. package/dist/abis/{googleIdentityVerifier.d.ts → ceremonyProofVerifier.d.ts} +146 -128
  3. package/dist/abis/{googleIdentityVerifier.d.ts.map → ceremonyProofVerifier.d.ts.map} +1 -1
  4. package/dist/abis/{googleIdentityVerifier.js → ceremonyProofVerifier.js} +182 -156
  5. package/dist/abis/ceremonyProofVerifier.js.map +1 -0
  6. package/dist/abis/{identityJwksRoots.d.ts → googleJwtRoots.d.ts} +273 -211
  7. package/dist/abis/{xZkVerifier.d.ts.map → googleJwtRoots.d.ts.map} +1 -1
  8. package/dist/abis/{identityJwksRoots.js → googleJwtRoots.js} +345 -253
  9. package/dist/abis/googleJwtRoots.js.map +1 -0
  10. package/dist/abis/{walletFactory.d.ts → handleResolver.d.ts} +185 -151
  11. package/dist/abis/handleResolver.d.ts.map +1 -0
  12. package/dist/abis/{walletFactory.js → handleResolver.js} +219 -170
  13. package/dist/abis/handleResolver.js.map +1 -0
  14. package/dist/abis/identityNames.d.ts +173 -219
  15. package/dist/abis/identityNames.d.ts.map +1 -1
  16. package/dist/abis/identityNames.js +210 -266
  17. package/dist/abis/identityNames.js.map +1 -1
  18. package/dist/abis/index.d.ts +4 -16
  19. package/dist/abis/index.d.ts.map +1 -1
  20. package/dist/abis/index.js +4 -16
  21. package/dist/abis/index.js.map +1 -1
  22. package/dist/abis/{xZkVerifier.d.ts → notaryService.d.ts} +237 -273
  23. package/dist/abis/{webWallet.d.ts.map → notaryService.d.ts.map} +1 -1
  24. package/dist/abis/{xZkVerifier.js → notaryService.js} +297 -337
  25. package/dist/abis/notaryService.js.map +1 -0
  26. package/dist/call.d.ts +7 -0
  27. package/dist/call.d.ts.map +1 -0
  28. package/dist/call.js +2 -0
  29. package/dist/call.js.map +1 -0
  30. package/dist/calls/ceremonyProofVerifier.d.ts +14 -0
  31. package/dist/calls/ceremonyProofVerifier.d.ts.map +1 -0
  32. package/dist/calls/ceremonyProofVerifier.js +55 -0
  33. package/dist/calls/ceremonyProofVerifier.js.map +1 -0
  34. package/dist/calls/googleJwtRoots.d.ts +14 -0
  35. package/dist/calls/googleJwtRoots.d.ts.map +1 -0
  36. package/dist/calls/googleJwtRoots.js +43 -0
  37. package/dist/calls/googleJwtRoots.js.map +1 -0
  38. package/dist/calls/handleResolver.d.ts +12 -0
  39. package/dist/calls/handleResolver.d.ts.map +1 -0
  40. package/dist/calls/handleResolver.js +29 -0
  41. package/dist/calls/handleResolver.js.map +1 -0
  42. package/dist/calls/identityNames.d.ts +16 -0
  43. package/dist/calls/identityNames.d.ts.map +1 -0
  44. package/dist/calls/identityNames.js +55 -0
  45. package/dist/calls/identityNames.js.map +1 -0
  46. package/dist/calls/index.d.ts +8 -0
  47. package/dist/calls/index.d.ts.map +1 -0
  48. package/dist/calls/index.js +10 -0
  49. package/dist/calls/index.js.map +1 -0
  50. package/dist/calls/libidFactory.d.ts +13 -0
  51. package/dist/calls/libidFactory.d.ts.map +1 -0
  52. package/dist/calls/libidFactory.js +36 -0
  53. package/dist/calls/libidFactory.js.map +1 -0
  54. package/dist/calls/notaryService.d.ts +16 -0
  55. package/dist/calls/notaryService.d.ts.map +1 -0
  56. package/dist/calls/notaryService.js +55 -0
  57. package/dist/calls/notaryService.js.map +1 -0
  58. package/dist/calls/wtia9.d.ts +13 -0
  59. package/dist/calls/wtia9.d.ts.map +1 -0
  60. package/dist/calls/wtia9.js +36 -0
  61. package/dist/calls/wtia9.js.map +1 -0
  62. package/dist/ceremony/index.d.ts +2 -0
  63. package/dist/ceremony/index.d.ts.map +1 -0
  64. package/dist/ceremony/index.js +13 -0
  65. package/dist/ceremony/index.js.map +1 -0
  66. package/dist/ceremony/profiles.d.ts +82 -0
  67. package/dist/ceremony/profiles.d.ts.map +1 -0
  68. package/dist/ceremony/profiles.js +86 -0
  69. package/dist/ceremony/profiles.js.map +1 -0
  70. package/dist/identity/handleVectors.d.ts +3 -3
  71. package/dist/identity/handleVectors.d.ts.map +1 -1
  72. package/dist/identity/handleVectors.js +3 -3
  73. package/dist/identity/handleVectors.js.map +1 -1
  74. package/dist/identity/index.d.ts +0 -1
  75. package/dist/identity/index.d.ts.map +1 -1
  76. package/dist/identity/index.js +7 -6
  77. package/dist/identity/index.js.map +1 -1
  78. package/dist/identity/resolve.js +4 -4
  79. package/dist/identity/resolve.js.map +1 -1
  80. package/dist/index.d.ts +3 -0
  81. package/dist/index.d.ts.map +1 -1
  82. package/dist/index.js +6 -3
  83. package/dist/index.js.map +1 -1
  84. package/package.json +12 -7
  85. package/src/abis/{googleIdentityVerifier.ts → ceremonyProofVerifier.ts} +181 -155
  86. package/src/abis/{identityJwksRoots.ts → googleJwtRoots.ts} +344 -252
  87. package/src/abis/{walletFactory.ts → handleResolver.ts} +218 -169
  88. package/src/abis/identityNames.ts +210 -266
  89. package/src/abis/index.ts +4 -16
  90. package/src/abis/{xZkVerifier.ts → notaryService.ts} +296 -336
  91. package/src/call.ts +15 -0
  92. package/src/calls/ceremonyProofVerifier.ts +90 -0
  93. package/src/calls/googleJwtRoots.ts +74 -0
  94. package/src/calls/handleResolver.ts +51 -0
  95. package/src/calls/identityNames.ts +88 -0
  96. package/src/calls/index.ts +9 -0
  97. package/src/calls/libidFactory.ts +63 -0
  98. package/src/calls/notaryService.ts +85 -0
  99. package/src/calls/wtia9.ts +52 -0
  100. package/src/ceremony/index.ts +13 -0
  101. package/src/ceremony/profiles.ts +151 -0
  102. package/src/identity/handleVectors.ts +3 -3
  103. package/src/identity/index.ts +7 -6
  104. package/src/identity/resolve.ts +4 -4
  105. package/src/index.ts +7 -3
  106. package/dist/abis/adminFacet.d.ts +0 -339
  107. package/dist/abis/adminFacet.d.ts.map +0 -1
  108. package/dist/abis/adminFacet.js +0 -442
  109. package/dist/abis/adminFacet.js.map +0 -1
  110. package/dist/abis/bank.d.ts +0 -916
  111. package/dist/abis/bank.d.ts.map +0 -1
  112. package/dist/abis/bank.js +0 -1184
  113. package/dist/abis/bank.js.map +0 -1
  114. package/dist/abis/diamondLoupeFacet.d.ts +0 -73
  115. package/dist/abis/diamondLoupeFacet.d.ts.map +0 -1
  116. package/dist/abis/diamondLoupeFacet.js +0 -100
  117. package/dist/abis/diamondLoupeFacet.js.map +0 -1
  118. package/dist/abis/gitHubIdentityVerifier.d.ts +0 -409
  119. package/dist/abis/gitHubIdentityVerifier.d.ts.map +0 -1
  120. package/dist/abis/gitHubIdentityVerifier.js +0 -531
  121. package/dist/abis/gitHubIdentityVerifier.js.map +0 -1
  122. package/dist/abis/googleIdentityVerifier.js.map +0 -1
  123. package/dist/abis/googleOidcVerifier.d.ts +0 -838
  124. package/dist/abis/googleOidcVerifier.d.ts.map +0 -1
  125. package/dist/abis/googleOidcVerifier.js +0 -1082
  126. package/dist/abis/googleOidcVerifier.js.map +0 -1
  127. package/dist/abis/identityJwksRoots.d.ts.map +0 -1
  128. package/dist/abis/identityJwksRoots.js.map +0 -1
  129. package/dist/abis/mockErc20.d.ts +0 -262
  130. package/dist/abis/mockErc20.d.ts.map +0 -1
  131. package/dist/abis/mockErc20.js +0 -347
  132. package/dist/abis/mockErc20.js.map +0 -1
  133. package/dist/abis/notary.d.ts +0 -263
  134. package/dist/abis/notary.d.ts.map +0 -1
  135. package/dist/abis/notary.js +0 -343
  136. package/dist/abis/notary.js.map +0 -1
  137. package/dist/abis/registry.d.ts +0 -1170
  138. package/dist/abis/registry.d.ts.map +0 -1
  139. package/dist/abis/registry.js +0 -1511
  140. package/dist/abis/registry.js.map +0 -1
  141. package/dist/abis/transferFacet.d.ts +0 -814
  142. package/dist/abis/transferFacet.d.ts.map +0 -1
  143. package/dist/abis/transferFacet.js +0 -1035
  144. package/dist/abis/transferFacet.js.map +0 -1
  145. package/dist/abis/vaultFacet.d.ts +0 -306
  146. package/dist/abis/vaultFacet.d.ts.map +0 -1
  147. package/dist/abis/vaultFacet.js +0 -398
  148. package/dist/abis/vaultFacet.js.map +0 -1
  149. package/dist/abis/walletFactory.d.ts.map +0 -1
  150. package/dist/abis/walletFactory.js.map +0 -1
  151. package/dist/abis/webWallet.d.ts +0 -523
  152. package/dist/abis/webWallet.js +0 -680
  153. package/dist/abis/webWallet.js.map +0 -1
  154. package/dist/abis/xIdentityVerifier.d.ts +0 -473
  155. package/dist/abis/xIdentityVerifier.d.ts.map +0 -1
  156. package/dist/abis/xIdentityVerifier.js +0 -612
  157. package/dist/abis/xIdentityVerifier.js.map +0 -1
  158. package/dist/abis/xZkVerifier.js.map +0 -1
  159. package/dist/identity/bind.d.ts +0 -59
  160. package/dist/identity/bind.d.ts.map +0 -1
  161. package/dist/identity/bind.fixtures.d.ts +0 -8
  162. package/dist/identity/bind.fixtures.d.ts.map +0 -1
  163. package/dist/identity/bind.fixtures.js +0 -55
  164. package/dist/identity/bind.fixtures.js.map +0 -1
  165. package/dist/identity/bind.js +0 -148
  166. package/dist/identity/bind.js.map +0 -1
  167. package/src/abis/adminFacet.ts +0 -444
  168. package/src/abis/bank.ts +0 -1186
  169. package/src/abis/diamondLoupeFacet.ts +0 -102
  170. package/src/abis/gitHubIdentityVerifier.ts +0 -533
  171. package/src/abis/googleOidcVerifier.ts +0 -1084
  172. package/src/abis/mockErc20.ts +0 -349
  173. package/src/abis/notary.ts +0 -345
  174. package/src/abis/registry.ts +0 -1513
  175. package/src/abis/transferFacet.ts +0 -1037
  176. package/src/abis/vaultFacet.ts +0 -400
  177. package/src/abis/webWallet.ts +0 -682
  178. package/src/abis/xIdentityVerifier.ts +0 -614
  179. package/src/identity/bind.fixtures.ts +0 -63
  180. package/src/identity/bind.ts +0 -243
@@ -1,243 +0,0 @@
1
- /// Binding a name: the write half.
2
- ///
3
- /// Reading a name is a view call and needs nothing. Writing one is a
4
- /// transaction the holder's own address sends, because `IdentityNames` requires
5
- /// the proof's target to be the caller — that single rule is the whole of the
6
- /// authorization, and it is why a proof read from the mempool is useless to
7
- /// anybody else.
8
- ///
9
- /// This module builds the calldata and nothing more. It does not sign, does not
10
- /// send, and does not know what kind of address the caller is: an EOA sends it
11
- /// directly, a smart account wraps it in whatever its own execute looks like.
12
- /// Keeping it at calldata is what lets a product with its own account model use
13
- /// the naming system without either side knowing about the other.
14
-
15
- import { type Address, encodeAbiParameters, encodeFunctionData, type Hex } from 'viem'
16
-
17
- import { identityNamesAbi } from '../abis/identityNames.js'
18
-
19
- /// The proof each platform's verifier takes, as it travels on chain.
20
- ///
21
- /// The verifier decodes one `bytes` argument, so a platform's fields are
22
- /// abi-encoded into it here. The shapes mirror the verifier structs exactly; a
23
- /// mismatch does not compile there and reverts here, which is why they are
24
- /// written out rather than built by hand at a call site.
25
-
26
- /// One notarized TLS session, as `GitHubIdentityVerifier` takes it.
27
- export interface TlsProof {
28
- notarySignature: Hex
29
- /// The address the proof is made out to. `IdentityNames` refuses a zero.
30
- walletAddress: Address
31
- domainHash: Hex
32
- clientRandom: Hex
33
- serverRandom: Hex
34
- serverEphemeralKey: Hex
35
- transcriptRoot: Hex
36
- timestamp: bigint
37
- domainPath: readonly Hex[]
38
- usernamePath: readonly Hex[]
39
- endpointPath: readonly Hex[]
40
- idPath: readonly Hex[]
41
- }
42
-
43
- export interface GitHubProof {
44
- tls: TlsProof
45
- domain: string
46
- handle: string
47
- userId: string
48
- endpoint: string
49
- }
50
-
51
- /// The notarized `/me` session, as `XIdentityVerifier` takes it. There is only
52
- /// one: a name binding does not read the OAuth client id, so it never asks for
53
- /// the `/token` session that exists to carry it.
54
- export interface MeAttestation {
55
- bearerHash: Hex
56
- bearerRangeStart: number
57
- bearerRangeEnd: number
58
- sentRevealed: Hex
59
- sentPrefixEnd: number
60
- sentSuffixEnd: number
61
- recvRevealed: Hex
62
- handle: string
63
- userId: string
64
- sessionAddr: Address
65
- timestamp: bigint
66
- notarySignature: Hex
67
- }
68
-
69
- export interface XProof {
70
- proof: Hex
71
- publicInputs: readonly Hex[]
72
- meAttest: MeAttestation
73
- }
74
-
75
- export interface GoogleProof {
76
- honkProof: Hex
77
- publicInputs: readonly Hex[]
78
- email: string
79
- /// The address inside the Google-signed nonce. This is the target, so it must
80
- /// be the address that will hold the name — the wallet, not a session key.
81
- sessionKey: Address
82
- sub: string
83
- }
84
-
85
- const tlsProofComponents = [
86
- { name: 'notarySignature', type: 'bytes' },
87
- { name: 'walletAddress', type: 'address' },
88
- { name: 'domainHash', type: 'bytes32' },
89
- { name: 'clientRandom', type: 'bytes32' },
90
- { name: 'serverRandom', type: 'bytes32' },
91
- { name: 'serverEphemeralKey', type: 'bytes' },
92
- { name: 'transcriptRoot', type: 'bytes32' },
93
- { name: 'timestamp', type: 'uint256' },
94
- { name: 'domainPath', type: 'bytes32[]' },
95
- { name: 'usernamePath', type: 'bytes32[]' },
96
- { name: 'endpointPath', type: 'bytes32[]' },
97
- { name: 'idPath', type: 'bytes32[]' },
98
- ] as const
99
-
100
- export function encodeGitHubProof(p: GitHubProof): Hex {
101
- return encodeAbiParameters(
102
- [
103
- {
104
- type: 'tuple',
105
- components: [
106
- { name: 'tls', type: 'tuple', components: tlsProofComponents },
107
- { name: 'domain', type: 'string' },
108
- { name: 'handle', type: 'string' },
109
- { name: 'userId', type: 'string' },
110
- { name: 'endpoint', type: 'string' },
111
- ],
112
- },
113
- ],
114
- [p],
115
- )
116
- }
117
-
118
- export function encodeXProof(p: XProof): Hex {
119
- return encodeAbiParameters(
120
- [
121
- {
122
- type: 'tuple',
123
- components: [
124
- { name: 'proof', type: 'bytes' },
125
- { name: 'publicInputs', type: 'bytes32[]' },
126
- {
127
- name: 'meAttest',
128
- type: 'tuple',
129
- components: [
130
- { name: 'bearerHash', type: 'bytes32' },
131
- { name: 'bearerRangeStart', type: 'uint32' },
132
- { name: 'bearerRangeEnd', type: 'uint32' },
133
- { name: 'sentRevealed', type: 'bytes' },
134
- { name: 'sentPrefixEnd', type: 'uint32' },
135
- { name: 'sentSuffixEnd', type: 'uint32' },
136
- { name: 'recvRevealed', type: 'bytes' },
137
- { name: 'handle', type: 'string' },
138
- { name: 'userId', type: 'string' },
139
- { name: 'sessionAddr', type: 'address' },
140
- { name: 'timestamp', type: 'uint64' },
141
- { name: 'notarySignature', type: 'bytes' },
142
- ],
143
- },
144
- ],
145
- },
146
- ],
147
- [p],
148
- )
149
- }
150
-
151
- export function encodeGoogleProof(p: GoogleProof): Hex {
152
- return encodeAbiParameters(
153
- [
154
- {
155
- type: 'tuple',
156
- components: [
157
- { name: 'honkProof', type: 'bytes' },
158
- { name: 'publicInputs', type: 'bytes32[]' },
159
- { name: 'email', type: 'string' },
160
- { name: 'sessionKey', type: 'address' },
161
- { name: 'sub', type: 'string' },
162
- ],
163
- },
164
- ],
165
- [p],
166
- )
167
- }
168
-
169
- /// One call, ready to send or to wrap.
170
- export interface Call {
171
- to: Address
172
- data: Hex
173
- }
174
-
175
- /// Bind a proven account to the caller.
176
- ///
177
- /// `publishName` also stores the handle as a string, so a contract can read the
178
- /// reverse direction on chain. The event carries the plaintext either way, so
179
- /// an indexer never needs it — say true only when something on chain must
180
- /// display the name. For Google the handle is an email address, which is worth
181
- /// a thought before publishing it.
182
- ///
183
- /// **The proof version is resolved on chain, at the moment the call lands** —
184
- /// not when this calldata is built. The day the owner moves a platform's
185
- /// default, this call starts handing the proof to the new format's verifier.
186
- /// That is right for a client that builds its proof fresh from this package
187
- /// each time, because both sides move together.
188
- ///
189
- /// It is wrong for a client pinned to one format: a shipped wallet that still
190
- /// encodes version 1 would hand version-1 bytes to a version-2 verifier, and
191
- /// the best case is an opaque revert. Such a client wants
192
- /// `bindAtVersionCall`.
193
- export function bindCall(names: Address, platformId: Hex, proof: Hex, publishName: boolean): Call {
194
- return {
195
- to: names,
196
- data: encodeFunctionData({
197
- abi: identityNamesAbi,
198
- functionName: 'bind',
199
- args: [platformId, proof, publishName],
200
- }),
201
- }
202
- }
203
-
204
- /// Bind with a named proof version.
205
- ///
206
- /// A platform's proof can change shape while the account behind it does not —
207
- /// X gaining OIDC, say — so several formats are accepted at once while users
208
- /// migrate. `bindCall` uses whichever version the platform currently defaults
209
- /// to, which is what a client building its proof fresh each time wants.
210
- ///
211
- /// Use this when the client is pinned to a format: a proof built for version 1
212
- /// keeps binding on the day the default moves to 2, and stops only when the
213
- /// owner retires version 1 outright.
214
- export function bindAtVersionCall(
215
- names: Address,
216
- platformId: Hex,
217
- version: number,
218
- proof: Hex,
219
- publishName: boolean,
220
- ): Call {
221
- return {
222
- to: names,
223
- data: encodeFunctionData({
224
- abi: identityNamesAbi,
225
- functionName: 'bindAtVersion',
226
- args: [platformId, version, proof, publishName],
227
- }),
228
- }
229
- }
230
-
231
- /// Withdraw a published handle. The binding itself stays: this stops the chain
232
- /// displaying the string, and needs no proof, because withdrawing what you
233
- /// chose to show must not depend on being able to log in again.
234
- export function unpublishCall(names: Address, platformId: Hex): Call {
235
- return {
236
- to: names,
237
- data: encodeFunctionData({
238
- abi: identityNamesAbi,
239
- functionName: 'unpublish',
240
- args: [platformId],
241
- }),
242
- }
243
- }