@lifi/perps-sdk-provider-ondo 34.0.0 → 35.0.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 (54) hide show
  1. package/dist/cjs/OndoProvider.d.ts.map +1 -1
  2. package/dist/cjs/OndoProvider.js +9 -1
  3. package/dist/cjs/OndoProvider.js.map +1 -1
  4. package/dist/cjs/auth/OndoClockDrift.d.ts +14 -0
  5. package/dist/cjs/auth/OndoClockDrift.d.ts.map +1 -0
  6. package/dist/cjs/auth/OndoClockDrift.js +48 -0
  7. package/dist/cjs/auth/OndoClockDrift.js.map +1 -0
  8. package/dist/cjs/auth/index.d.ts +1 -0
  9. package/dist/cjs/auth/index.d.ts.map +1 -1
  10. package/dist/cjs/auth/index.js +3 -1
  11. package/dist/cjs/auth/index.js.map +1 -1
  12. package/dist/cjs/auth/signActions.d.ts +2 -0
  13. package/dist/cjs/auth/signActions.d.ts.map +1 -1
  14. package/dist/cjs/auth/signActions.js +1 -1
  15. package/dist/cjs/auth/signActions.js.map +1 -1
  16. package/dist/cjs/types/wire.d.ts +4 -0
  17. package/dist/cjs/types/wire.d.ts.map +1 -1
  18. package/dist/esm/OndoProvider.d.ts.map +1 -1
  19. package/dist/esm/OndoProvider.js +12 -1
  20. package/dist/esm/OndoProvider.js.map +1 -1
  21. package/dist/esm/auth/OndoClockDrift.d.ts +27 -0
  22. package/dist/esm/auth/OndoClockDrift.d.ts.map +1 -0
  23. package/dist/esm/auth/OndoClockDrift.js +58 -0
  24. package/dist/esm/auth/OndoClockDrift.js.map +1 -0
  25. package/dist/esm/auth/hmac.d.ts +1 -1
  26. package/dist/esm/auth/hmac.d.ts.map +1 -1
  27. package/dist/esm/auth/index.d.ts +1 -0
  28. package/dist/esm/auth/index.d.ts.map +1 -1
  29. package/dist/esm/auth/index.js +1 -0
  30. package/dist/esm/auth/index.js.map +1 -1
  31. package/dist/esm/auth/signActions.d.ts +6 -2
  32. package/dist/esm/auth/signActions.d.ts.map +1 -1
  33. package/dist/esm/auth/signActions.js +5 -4
  34. package/dist/esm/auth/signActions.js.map +1 -1
  35. package/dist/esm/types/wire.d.ts +6 -0
  36. package/dist/esm/types/wire.d.ts.map +1 -1
  37. package/dist/types/OndoProvider.d.ts.map +1 -1
  38. package/dist/types/auth/OndoClockDrift.d.ts +27 -0
  39. package/dist/types/auth/OndoClockDrift.d.ts.map +1 -0
  40. package/dist/types/auth/hmac.d.ts +1 -1
  41. package/dist/types/auth/hmac.d.ts.map +1 -1
  42. package/dist/types/auth/index.d.ts +1 -0
  43. package/dist/types/auth/index.d.ts.map +1 -1
  44. package/dist/types/auth/signActions.d.ts +6 -2
  45. package/dist/types/auth/signActions.d.ts.map +1 -1
  46. package/dist/types/types/wire.d.ts +6 -0
  47. package/dist/types/types/wire.d.ts.map +1 -1
  48. package/package.json +3 -3
  49. package/src/OndoProvider.ts +17 -2
  50. package/src/auth/OndoClockDrift.ts +67 -0
  51. package/src/auth/hmac.ts +1 -1
  52. package/src/auth/index.ts +1 -0
  53. package/src/auth/signActions.ts +7 -4
  54. package/src/types/wire.ts +7 -0
package/src/auth/index.ts CHANGED
@@ -6,6 +6,7 @@ export {
6
6
  } from './completeSiweLogin.js'
7
7
  export { hmacSignRequest, type OndoHmacRequest } from './hmac.js'
8
8
  export { OndoApiKeyStore } from './OndoApiKeyStore.js'
9
+ export { OndoClockDrift } from './OndoClockDrift.js'
9
10
  export { OndoTokenStore } from './OndoTokenStore.js'
10
11
  export {
11
12
  type OndoSignActionsDeps,
@@ -43,6 +43,7 @@ import {
43
43
  isOndoApiKey,
44
44
  type OndoApiKeyStore,
45
45
  } from './OndoApiKeyStore.js'
46
+ import type { OndoClockDrift } from './OndoClockDrift.js'
46
47
  import type { OndoTokenStore } from './OndoTokenStore.js'
47
48
  import { requireOndoSessionToken } from './sessionToken.js'
48
49
 
@@ -51,6 +52,7 @@ export interface OndoSignActionsDeps {
51
52
  client: OndoApiClient
52
53
  tokenStore: OndoTokenStore
53
54
  apiKeyStore: OndoApiKeyStore
55
+ clockDrift: OndoClockDrift
54
56
  }
55
57
 
56
58
  const ONDO_API_KEY_LIMIT = 10
@@ -273,8 +275,10 @@ async function executeSessionRequest(
273
275
  *
274
276
  * `HMAC` computes a per-request HMAC-SHA256 signature over each request step
275
277
  * from the client-held API key (creating one on first use), attaching the
276
- * `hmac` material. The signed step rides the normal `executeAction` path; the
277
- * API secret itself never leaves the client.
278
+ * `hmac` material. The timestamp is the device clock corrected by
279
+ * `OndoClockDrift`, which measures the drift after Ondo refuses a timestamp. The
280
+ * signed step rides the normal `executeAction` path; the API secret itself
281
+ * never leaves the client.
278
282
  *
279
283
  * @public
280
284
  */
@@ -320,8 +324,7 @@ export async function ondoSignActions(
320
324
  `Ondo received a step without a request ('${step.action}') under the hmac signing method.`
321
325
  )
322
326
  }
323
- // Stamped immediately before executeAction; Ondo enforces a 30s window.
324
- const timestampMs = Date.now()
327
+ const timestampMs = await deps.clockDrift.nowMs()
325
328
  const signature = await hmacSignRequest(apiKey.apiSecret, {
326
329
  timestampMs,
327
330
  method: step.request.method,
package/src/types/wire.ts CHANGED
@@ -435,3 +435,10 @@ export interface OndoRestMarkPrice {
435
435
  lastExternalPrice: string
436
436
  lastUpdatedTime: string
437
437
  }
438
+
439
+ /** Mirrors Ondo's `StatusResult` (the `/status` result). @public */
440
+ export interface OndoStatus {
441
+ marketStatus: string
442
+ /** Ondo's clock, in Unix milliseconds. */
443
+ serverTime: number
444
+ }