tempo.ts 0.12.0 → 0.13.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 (123) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/README.md +28 -34
  3. package/package.json +2 -28
  4. package/dist/wagmi/Actions/amm.d.ts +0 -418
  5. package/dist/wagmi/Actions/amm.d.ts.map +0 -1
  6. package/dist/wagmi/Actions/amm.js +0 -462
  7. package/dist/wagmi/Actions/amm.js.map +0 -1
  8. package/dist/wagmi/Actions/dex.d.ts +0 -864
  9. package/dist/wagmi/Actions/dex.d.ts.map +0 -1
  10. package/dist/wagmi/Actions/dex.js +0 -968
  11. package/dist/wagmi/Actions/dex.js.map +0 -1
  12. package/dist/wagmi/Actions/faucet.d.ts +0 -66
  13. package/dist/wagmi/Actions/faucet.d.ts.map +0 -1
  14. package/dist/wagmi/Actions/faucet.js +0 -64
  15. package/dist/wagmi/Actions/faucet.js.map +0 -1
  16. package/dist/wagmi/Actions/fee.d.ts +0 -111
  17. package/dist/wagmi/Actions/fee.d.ts.map +0 -1
  18. package/dist/wagmi/Actions/fee.js +0 -126
  19. package/dist/wagmi/Actions/fee.js.map +0 -1
  20. package/dist/wagmi/Actions/index.d.ts +0 -9
  21. package/dist/wagmi/Actions/index.d.ts.map +0 -1
  22. package/dist/wagmi/Actions/index.js +0 -9
  23. package/dist/wagmi/Actions/index.js.map +0 -1
  24. package/dist/wagmi/Actions/nonce.d.ts +0 -77
  25. package/dist/wagmi/Actions/nonce.d.ts.map +0 -1
  26. package/dist/wagmi/Actions/nonce.js +0 -87
  27. package/dist/wagmi/Actions/nonce.js.map +0 -1
  28. package/dist/wagmi/Actions/policy.d.ts +0 -480
  29. package/dist/wagmi/Actions/policy.d.ts.map +0 -1
  30. package/dist/wagmi/Actions/policy.js +0 -530
  31. package/dist/wagmi/Actions/policy.js.map +0 -1
  32. package/dist/wagmi/Actions/reward.d.ts +0 -346
  33. package/dist/wagmi/Actions/reward.d.ts.map +0 -1
  34. package/dist/wagmi/Actions/reward.js +0 -382
  35. package/dist/wagmi/Actions/reward.js.map +0 -1
  36. package/dist/wagmi/Actions/token.d.ts +0 -1546
  37. package/dist/wagmi/Actions/token.d.ts.map +0 -1
  38. package/dist/wagmi/Actions/token.js +0 -1712
  39. package/dist/wagmi/Actions/token.js.map +0 -1
  40. package/dist/wagmi/Connector.d.ts +0 -91
  41. package/dist/wagmi/Connector.d.ts.map +0 -1
  42. package/dist/wagmi/Connector.js +0 -473
  43. package/dist/wagmi/Connector.js.map +0 -1
  44. package/dist/wagmi/Hooks/amm.d.ts +0 -411
  45. package/dist/wagmi/Hooks/amm.d.ts.map +0 -1
  46. package/dist/wagmi/Hooks/amm.js +0 -494
  47. package/dist/wagmi/Hooks/amm.js.map +0 -1
  48. package/dist/wagmi/Hooks/dex.d.ts +0 -773
  49. package/dist/wagmi/Hooks/dex.d.ts.map +0 -1
  50. package/dist/wagmi/Hooks/dex.js +0 -921
  51. package/dist/wagmi/Hooks/dex.js.map +0 -1
  52. package/dist/wagmi/Hooks/faucet.d.ts +0 -71
  53. package/dist/wagmi/Hooks/faucet.d.ts.map +0 -1
  54. package/dist/wagmi/Hooks/faucet.js +0 -76
  55. package/dist/wagmi/Hooks/faucet.js.map +0 -1
  56. package/dist/wagmi/Hooks/fee.d.ts +0 -97
  57. package/dist/wagmi/Hooks/fee.d.ts.map +0 -1
  58. package/dist/wagmi/Hooks/fee.js +0 -109
  59. package/dist/wagmi/Hooks/fee.js.map +0 -1
  60. package/dist/wagmi/Hooks/index.d.ts +0 -9
  61. package/dist/wagmi/Hooks/index.d.ts.map +0 -1
  62. package/dist/wagmi/Hooks/index.js +0 -9
  63. package/dist/wagmi/Hooks/index.js.map +0 -1
  64. package/dist/wagmi/Hooks/nonce.d.ts +0 -59
  65. package/dist/wagmi/Hooks/nonce.d.ts.map +0 -1
  66. package/dist/wagmi/Hooks/nonce.js +0 -75
  67. package/dist/wagmi/Hooks/nonce.js.map +0 -1
  68. package/dist/wagmi/Hooks/policy.d.ts +0 -423
  69. package/dist/wagmi/Hooks/policy.d.ts.map +0 -1
  70. package/dist/wagmi/Hooks/policy.js +0 -510
  71. package/dist/wagmi/Hooks/policy.js.map +0 -1
  72. package/dist/wagmi/Hooks/reward.d.ts +0 -305
  73. package/dist/wagmi/Hooks/reward.d.ts.map +0 -1
  74. package/dist/wagmi/Hooks/reward.js +0 -368
  75. package/dist/wagmi/Hooks/reward.js.map +0 -1
  76. package/dist/wagmi/Hooks/token.d.ts +0 -1388
  77. package/dist/wagmi/Hooks/token.d.ts.map +0 -1
  78. package/dist/wagmi/Hooks/token.js +0 -1657
  79. package/dist/wagmi/Hooks/token.js.map +0 -1
  80. package/dist/wagmi/KeyManager.d.ts +0 -60
  81. package/dist/wagmi/KeyManager.d.ts.map +0 -1
  82. package/dist/wagmi/KeyManager.js +0 -106
  83. package/dist/wagmi/KeyManager.js.map +0 -1
  84. package/dist/wagmi/index.d.ts +0 -5
  85. package/dist/wagmi/index.d.ts.map +0 -1
  86. package/dist/wagmi/index.js +0 -5
  87. package/dist/wagmi/index.js.map +0 -1
  88. package/src/wagmi/Actions/amm.test.ts +0 -208
  89. package/src/wagmi/Actions/amm.ts +0 -690
  90. package/src/wagmi/Actions/dex.test.ts +0 -1482
  91. package/src/wagmi/Actions/dex.ts +0 -1540
  92. package/src/wagmi/Actions/faucet.ts +0 -89
  93. package/src/wagmi/Actions/fee.test.ts +0 -63
  94. package/src/wagmi/Actions/fee.ts +0 -211
  95. package/src/wagmi/Actions/index.ts +0 -8
  96. package/src/wagmi/Actions/nonce.test.ts +0 -82
  97. package/src/wagmi/Actions/nonce.ts +0 -139
  98. package/src/wagmi/Actions/policy.test.ts +0 -461
  99. package/src/wagmi/Actions/policy.ts +0 -817
  100. package/src/wagmi/Actions/reward.test.ts +0 -216
  101. package/src/wagmi/Actions/reward.ts +0 -613
  102. package/src/wagmi/Actions/token.test.ts +0 -1309
  103. package/src/wagmi/Actions/token.ts +0 -2644
  104. package/src/wagmi/Connector.test.ts +0 -56
  105. package/src/wagmi/Connector.ts +0 -670
  106. package/src/wagmi/Hooks/amm.test.ts +0 -564
  107. package/src/wagmi/Hooks/amm.ts +0 -796
  108. package/src/wagmi/Hooks/dex.test.ts +0 -992
  109. package/src/wagmi/Hooks/dex.ts +0 -1598
  110. package/src/wagmi/Hooks/faucet.ts +0 -144
  111. package/src/wagmi/Hooks/fee.test.ts +0 -166
  112. package/src/wagmi/Hooks/fee.ts +0 -206
  113. package/src/wagmi/Hooks/index.ts +0 -8
  114. package/src/wagmi/Hooks/nonce.test.ts +0 -142
  115. package/src/wagmi/Hooks/nonce.ts +0 -117
  116. package/src/wagmi/Hooks/policy.test.ts +0 -665
  117. package/src/wagmi/Hooks/policy.ts +0 -873
  118. package/src/wagmi/Hooks/reward.test.ts +0 -249
  119. package/src/wagmi/Hooks/reward.ts +0 -645
  120. package/src/wagmi/Hooks/token.test.ts +0 -1183
  121. package/src/wagmi/Hooks/token.ts +0 -2906
  122. package/src/wagmi/KeyManager.ts +0 -172
  123. package/src/wagmi/index.ts +0 -7
@@ -1,172 +0,0 @@
1
- import type * as Hex from 'ox/Hex'
2
- import * as Json from 'ox/Json'
3
- import {
4
- type CreateStorageParameters,
5
- createStorage,
6
- type Storage,
7
- } from 'wagmi'
8
- import type * as Handler from '../server/Handler.js'
9
-
10
- export type KeyManager = {
11
- /** Function to fetch create options for WebAuthn. */
12
- getChallenge?:
13
- | (() => Promise<Handler.keyManager.ChallengeResponse>)
14
- | undefined
15
- /** Function to fetch the public key for a credential. */
16
- getPublicKey: (
17
- parameters: Handler.keyManager.GetPublicKeyParameters,
18
- ) => Promise<Hex.Hex>
19
- /** Function to set the public key for a credential. */
20
- setPublicKey: (
21
- parameters: Handler.keyManager.SetPublicKeyParameters,
22
- ) => Promise<void>
23
- }
24
-
25
- /** Instantiates a key manager. */
26
- export function from<manager extends KeyManager>(manager: manager): manager {
27
- return manager
28
- }
29
-
30
- /** Instantiates a key manager from a Storage instance. */
31
- export function fromStorage(storage: Storage): KeyManager {
32
- return from({
33
- async getPublicKey(parameters) {
34
- const publicKey = await storage.getItem(parameters.credential.id)
35
- if (!publicKey) throw new Error('publicKey not found.')
36
- return publicKey as Hex.Hex
37
- },
38
- async setPublicKey(parameters) {
39
- await storage.setItem(parameters.credential.id, parameters.publicKey)
40
- },
41
- })
42
- }
43
-
44
- /**
45
- * Instantiates a key manager from a localStorage instance.
46
- *
47
- * WARNING: Do not use this in production.
48
- * This is because we are unable to extract a user's public key after the registration
49
- * process. If a user clears their storage, or visits the website on a different device,
50
- * they will not be able to access their account.
51
- *
52
- * Instead, we recommend to set up a remote store such as [`KeyManager.http`](#http) to register
53
- * public keys against their WebAuthn credential.
54
- *
55
- * @see {@link http}
56
- *
57
- * @deprecated
58
- */
59
- export function localStorage(options: localStorage.Options = {}) {
60
- const { key = 'wagmi.keyManager' } = options
61
- const storage = createStorage({
62
- ...options,
63
- key,
64
- storage: typeof window !== 'undefined' ? window.localStorage : undefined,
65
- })
66
- return fromStorage(storage)
67
- }
68
-
69
- export namespace localStorage {
70
- export type Options = Omit<CreateStorageParameters, 'storage'>
71
- }
72
-
73
- /**
74
- * Instantiates a key manager that uses HTTP endpoints for credential management.
75
- *
76
- * @example
77
- * ```tsx
78
- * import { KeyManager } from 'tempo.ts/wagmi'
79
- *
80
- * const keyManager = KeyManager.http('https://api.example.com')
81
- * ```
82
- *
83
- * @param url - The URL to use for the HTTP endpoints.
84
- * @param options - Configuration options for HTTP endpoints.
85
- * @returns A KeyManager instance that uses HTTP for credential operations.
86
- */
87
- export function http(
88
- url:
89
- | string
90
- | {
91
- getChallenge?: string | Request | undefined
92
- getPublicKey?: string | Request | undefined
93
- setPublicKey?: string | Request | undefined
94
- },
95
- options: http.Options = {},
96
- ): KeyManager {
97
- const { fetch: fetchFn = globalThis.fetch } = options
98
- const { getChallenge, getPublicKey, setPublicKey } = (() => {
99
- const base = typeof url === 'string' ? url : ''
100
- const urls = typeof url === 'object' ? url : {}
101
- return {
102
- getChallenge: urls.getChallenge ?? `${base}/challenge`,
103
- getPublicKey: urls.getPublicKey ?? `${base}/:credentialId`,
104
- setPublicKey: urls.setPublicKey ?? `${base}/:credentialId`,
105
- }
106
- })()
107
-
108
- return from({
109
- async getChallenge() {
110
- const request =
111
- getChallenge instanceof Request
112
- ? getChallenge
113
- : new Request(getChallenge)
114
-
115
- const response = await fetchFn(request)
116
-
117
- if (!response.ok)
118
- throw new Error(`Failed to get create options: ${response.statusText}`)
119
- return await response.json()
120
- },
121
-
122
- async getPublicKey(parameters) {
123
- const request =
124
- getPublicKey instanceof Request
125
- ? getPublicKey
126
- : new Request(getPublicKey)
127
-
128
- const response = await fetchFn(
129
- new Request(
130
- request.url.replace(':credentialId', parameters.credential.id),
131
- request,
132
- ),
133
- )
134
-
135
- if (!response.ok)
136
- throw new Error(`Failed to get public key: ${response.statusText}`)
137
- const data = await response.json()
138
- return data.publicKey as Hex.Hex
139
- },
140
-
141
- async setPublicKey(parameters) {
142
- const request =
143
- setPublicKey instanceof Request
144
- ? setPublicKey
145
- : new Request(setPublicKey)
146
-
147
- const response = await fetchFn(
148
- new Request(
149
- request.url.replace(':credentialId', parameters.credential.id),
150
- request,
151
- ),
152
- {
153
- method: 'POST',
154
- headers: {
155
- 'Content-Type': 'application/json',
156
- },
157
- body: Json.stringify(parameters),
158
- },
159
- )
160
-
161
- if (!response.ok)
162
- throw new Error(`Failed to set public key: ${response.statusText}`)
163
- },
164
- })
165
- }
166
-
167
- export namespace http {
168
- export type Options = {
169
- /** Custom fetch function. @default `globalThis.fetch`. */
170
- fetch?: typeof fetch | undefined
171
- }
172
- }
@@ -1,7 +0,0 @@
1
- export * as Actions from './Actions/index.js'
2
- export {
3
- dangerous_secp256k1,
4
- webAuthn,
5
- } from './Connector.js'
6
- export * as Hooks from './Hooks/index.js'
7
- export * as KeyManager from './KeyManager.js'