@wagmi/core 3.0.2 → 3.1.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 (83) hide show
  1. package/dist/esm/exports/internal.js.map +1 -1
  2. package/dist/esm/exports/query.js +1 -1
  3. package/dist/esm/exports/query.js.map +1 -1
  4. package/dist/esm/exports/tempo.js +9 -0
  5. package/dist/esm/exports/tempo.js.map +1 -0
  6. package/dist/esm/tempo/Actions/amm.js +469 -0
  7. package/dist/esm/tempo/Actions/amm.js.map +1 -0
  8. package/dist/esm/tempo/Actions/dex.js +983 -0
  9. package/dist/esm/tempo/Actions/dex.js.map +1 -0
  10. package/dist/esm/tempo/Actions/faucet.js +64 -0
  11. package/dist/esm/tempo/Actions/faucet.js.map +1 -0
  12. package/dist/esm/tempo/Actions/fee.js +160 -0
  13. package/dist/esm/tempo/Actions/fee.js.map +1 -0
  14. package/dist/esm/tempo/Actions/index.js +11 -0
  15. package/dist/esm/tempo/Actions/index.js.map +1 -0
  16. package/dist/esm/tempo/Actions/nonce.js +176 -0
  17. package/dist/esm/tempo/Actions/nonce.js.map +1 -0
  18. package/dist/esm/tempo/Actions/policy.js +532 -0
  19. package/dist/esm/tempo/Actions/policy.js.map +1 -0
  20. package/dist/esm/tempo/Actions/reward.js +384 -0
  21. package/dist/esm/tempo/Actions/reward.js.map +1 -0
  22. package/dist/esm/tempo/Actions/token.js +1717 -0
  23. package/dist/esm/tempo/Actions/token.js.map +1 -0
  24. package/dist/esm/tempo/Actions/utils.js +2 -0
  25. package/dist/esm/tempo/Actions/utils.js.map +1 -0
  26. package/dist/esm/tempo/Connectors.js +534 -0
  27. package/dist/esm/tempo/Connectors.js.map +1 -0
  28. package/dist/esm/tempo/KeyManager.js +106 -0
  29. package/dist/esm/tempo/KeyManager.js.map +1 -0
  30. package/dist/esm/tsconfig.build.tsbuildinfo +1 -1
  31. package/dist/esm/version.js +1 -1
  32. package/dist/types/exports/internal.d.ts +1 -1
  33. package/dist/types/exports/internal.d.ts.map +1 -1
  34. package/dist/types/exports/query.d.ts +1 -1
  35. package/dist/types/exports/query.d.ts.map +1 -1
  36. package/dist/types/exports/tempo.d.ts +5 -0
  37. package/dist/types/exports/tempo.d.ts.map +1 -0
  38. package/dist/types/tempo/Actions/amm.d.ts +418 -0
  39. package/dist/types/tempo/Actions/amm.d.ts.map +1 -0
  40. package/dist/types/tempo/Actions/dex.d.ts +858 -0
  41. package/dist/types/tempo/Actions/dex.d.ts.map +1 -0
  42. package/dist/types/tempo/Actions/faucet.d.ts +70 -0
  43. package/dist/types/tempo/Actions/faucet.d.ts.map +1 -0
  44. package/dist/types/tempo/Actions/fee.d.ts +141 -0
  45. package/dist/types/tempo/Actions/fee.d.ts.map +1 -0
  46. package/dist/types/tempo/Actions/index.d.ts +10 -0
  47. package/dist/types/tempo/Actions/index.d.ts.map +1 -0
  48. package/dist/types/tempo/Actions/nonce.d.ts +150 -0
  49. package/dist/types/tempo/Actions/nonce.d.ts.map +1 -0
  50. package/dist/types/tempo/Actions/policy.d.ts +478 -0
  51. package/dist/types/tempo/Actions/policy.d.ts.map +1 -0
  52. package/dist/types/tempo/Actions/reward.d.ts +340 -0
  53. package/dist/types/tempo/Actions/reward.d.ts.map +1 -0
  54. package/dist/types/tempo/Actions/token.d.ts +1531 -0
  55. package/dist/types/tempo/Actions/token.d.ts.map +1 -0
  56. package/dist/types/tempo/Actions/utils.d.ts +9 -0
  57. package/dist/types/tempo/Actions/utils.d.ts.map +1 -0
  58. package/dist/types/tempo/Connectors.d.ts +99 -0
  59. package/dist/types/tempo/Connectors.d.ts.map +1 -0
  60. package/dist/types/tempo/KeyManager.d.ts +71 -0
  61. package/dist/types/tempo/KeyManager.d.ts.map +1 -0
  62. package/dist/types/types/utils.d.ts +16 -0
  63. package/dist/types/types/utils.d.ts.map +1 -1
  64. package/dist/types/version.d.ts +1 -1
  65. package/package.json +14 -2
  66. package/src/exports/internal.ts +3 -0
  67. package/src/exports/query.ts +4 -1
  68. package/src/exports/tempo.ts +14 -0
  69. package/src/tempo/Actions/amm.ts +719 -0
  70. package/src/tempo/Actions/dex.ts +1571 -0
  71. package/src/tempo/Actions/faucet.ts +95 -0
  72. package/src/tempo/Actions/fee.ts +259 -0
  73. package/src/tempo/Actions/index.ts +10 -0
  74. package/src/tempo/Actions/nonce.ts +283 -0
  75. package/src/tempo/Actions/policy.ts +827 -0
  76. package/src/tempo/Actions/reward.ts +621 -0
  77. package/src/tempo/Actions/token.ts +2598 -0
  78. package/src/tempo/Actions/utils.ts +26 -0
  79. package/src/tempo/Connectors.ts +762 -0
  80. package/src/tempo/KeyManager.ts +176 -0
  81. package/src/types/utils.ts +19 -0
  82. package/src/version.ts +1 -1
  83. package/tempo/package.json +5 -0
@@ -0,0 +1,106 @@
1
+ import * as Json from 'ox/Json';
2
+ import { createStorage, } from '../createStorage.js';
3
+ /** Instantiates a key manager. */
4
+ export function from(manager) {
5
+ return manager;
6
+ }
7
+ /** Instantiates a key manager from a Storage instance. */
8
+ export function fromStorage(storage) {
9
+ return from({
10
+ async getPublicKey(parameters) {
11
+ const publicKey = await storage.getItem(parameters.credential.id);
12
+ if (!publicKey)
13
+ throw new Error('publicKey not found.');
14
+ return publicKey;
15
+ },
16
+ async setPublicKey(parameters) {
17
+ await storage.setItem(parameters.credential.id, parameters.publicKey);
18
+ },
19
+ });
20
+ }
21
+ /**
22
+ * Instantiates a key manager from a localStorage instance.
23
+ *
24
+ * WARNING: Do not use this in production.
25
+ * This is because we are unable to extract a user's public key after the registration
26
+ * process. If a user clears their storage, or visits the website on a different device,
27
+ * they will not be able to access their account.
28
+ *
29
+ * Instead, we recommend to set up a remote store such as [`KeyManager.http`](#http) to register
30
+ * public keys against their WebAuthn credential.
31
+ *
32
+ * @see {@link http}
33
+ *
34
+ * @deprecated
35
+ */
36
+ export function localStorage(options = {}) {
37
+ const { key = 'wagmi.keyManager' } = options;
38
+ const storage = createStorage({
39
+ ...options,
40
+ key,
41
+ storage: typeof window !== 'undefined' ? window.localStorage : undefined,
42
+ });
43
+ return fromStorage(storage);
44
+ }
45
+ /**
46
+ * Instantiates a key manager that uses HTTP endpoints for credential management.
47
+ *
48
+ * @example
49
+ * ```tsx
50
+ * import { KeyManager } from '@wagmi/core/tempo'
51
+ *
52
+ * const keyManager = KeyManager.http('https://api.example.com')
53
+ * ```
54
+ *
55
+ * @param url - The URL to use for the HTTP endpoints.
56
+ * @param options - Configuration options for HTTP endpoints.
57
+ * @returns A KeyManager instance that uses HTTP for credential operations.
58
+ */
59
+ export function http(url, options = {}) {
60
+ const { fetch: fetchFn = globalThis.fetch } = options;
61
+ const { getChallenge, getPublicKey, setPublicKey } = (() => {
62
+ const base = typeof url === 'string' ? url : '';
63
+ const urls = typeof url === 'object' ? url : {};
64
+ return {
65
+ getChallenge: urls.getChallenge ?? `${base}/challenge`,
66
+ getPublicKey: urls.getPublicKey ?? `${base}/:credentialId`,
67
+ setPublicKey: urls.setPublicKey ?? `${base}/:credentialId`,
68
+ };
69
+ })();
70
+ return from({
71
+ async getChallenge() {
72
+ const request = getChallenge instanceof Request
73
+ ? getChallenge
74
+ : new Request(getChallenge);
75
+ const response = await fetchFn(request);
76
+ if (!response.ok)
77
+ throw new Error(`Failed to get create options: ${response.statusText}`);
78
+ return await response.json();
79
+ },
80
+ async getPublicKey(parameters) {
81
+ const request = getPublicKey instanceof Request
82
+ ? getPublicKey
83
+ : new Request(getPublicKey);
84
+ const response = await fetchFn(new Request(request.url.replace(':credentialId', parameters.credential.id), request));
85
+ if (!response.ok)
86
+ throw new Error(`Failed to get public key: ${response.statusText}`);
87
+ const data = await response.json();
88
+ return data.publicKey;
89
+ },
90
+ async setPublicKey(parameters) {
91
+ const request = setPublicKey instanceof Request
92
+ ? setPublicKey
93
+ : new Request(setPublicKey);
94
+ const response = await fetchFn(new Request(request.url.replace(':credentialId', parameters.credential.id), request), {
95
+ method: 'POST',
96
+ headers: {
97
+ 'Content-Type': 'application/json',
98
+ },
99
+ body: Json.stringify(parameters),
100
+ });
101
+ if (!response.ok)
102
+ throw new Error(`Failed to set public key: ${response.statusText}`);
103
+ },
104
+ });
105
+ }
106
+ //# sourceMappingURL=KeyManager.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"KeyManager.js","sourceRoot":"","sources":["../../../src/tempo/KeyManager.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,IAAI,MAAM,SAAS,CAAA;AAC/B,OAAO,EAEL,aAAa,GAEd,MAAM,qBAAqB,CAAA;AAqB5B,kCAAkC;AAClC,MAAM,UAAU,IAAI,CAA6B,OAAgB;IAC/D,OAAO,OAAO,CAAA;AAChB,CAAC;AAED,0DAA0D;AAC1D,MAAM,UAAU,WAAW,CAAC,OAAgB;IAC1C,OAAO,IAAI,CAAC;QACV,KAAK,CAAC,YAAY,CAAC,UAAU;YAC3B,MAAM,SAAS,GAAG,MAAM,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC,CAAA;YACjE,IAAI,CAAC,SAAS;gBAAE,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAA;YACvD,OAAO,SAAoB,CAAA;QAC7B,CAAC;QACD,KAAK,CAAC,YAAY,CAAC,UAAU;YAC3B,MAAM,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,EAAE,UAAU,CAAC,SAAS,CAAC,CAAA;QACvE,CAAC;KACF,CAAC,CAAA;AACJ,CAAC;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,YAAY,CAAC,UAAgC,EAAE;IAC7D,MAAM,EAAE,GAAG,GAAG,kBAAkB,EAAE,GAAG,OAAO,CAAA;IAC5C,MAAM,OAAO,GAAG,aAAa,CAAC;QAC5B,GAAG,OAAO;QACV,GAAG;QACH,OAAO,EAAE,OAAO,MAAM,KAAK,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC,SAAS;KACzE,CAAC,CAAA;IACF,OAAO,WA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