@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.
- package/dist/cjs/OndoProvider.d.ts.map +1 -1
- package/dist/cjs/OndoProvider.js +9 -1
- package/dist/cjs/OndoProvider.js.map +1 -1
- package/dist/cjs/auth/OndoClockDrift.d.ts +14 -0
- package/dist/cjs/auth/OndoClockDrift.d.ts.map +1 -0
- package/dist/cjs/auth/OndoClockDrift.js +48 -0
- package/dist/cjs/auth/OndoClockDrift.js.map +1 -0
- package/dist/cjs/auth/index.d.ts +1 -0
- package/dist/cjs/auth/index.d.ts.map +1 -1
- package/dist/cjs/auth/index.js +3 -1
- package/dist/cjs/auth/index.js.map +1 -1
- package/dist/cjs/auth/signActions.d.ts +2 -0
- package/dist/cjs/auth/signActions.d.ts.map +1 -1
- package/dist/cjs/auth/signActions.js +1 -1
- package/dist/cjs/auth/signActions.js.map +1 -1
- package/dist/cjs/types/wire.d.ts +4 -0
- package/dist/cjs/types/wire.d.ts.map +1 -1
- package/dist/esm/OndoProvider.d.ts.map +1 -1
- package/dist/esm/OndoProvider.js +12 -1
- package/dist/esm/OndoProvider.js.map +1 -1
- package/dist/esm/auth/OndoClockDrift.d.ts +27 -0
- package/dist/esm/auth/OndoClockDrift.d.ts.map +1 -0
- package/dist/esm/auth/OndoClockDrift.js +58 -0
- package/dist/esm/auth/OndoClockDrift.js.map +1 -0
- package/dist/esm/auth/hmac.d.ts +1 -1
- package/dist/esm/auth/hmac.d.ts.map +1 -1
- package/dist/esm/auth/index.d.ts +1 -0
- package/dist/esm/auth/index.d.ts.map +1 -1
- package/dist/esm/auth/index.js +1 -0
- package/dist/esm/auth/index.js.map +1 -1
- package/dist/esm/auth/signActions.d.ts +6 -2
- package/dist/esm/auth/signActions.d.ts.map +1 -1
- package/dist/esm/auth/signActions.js +5 -4
- package/dist/esm/auth/signActions.js.map +1 -1
- package/dist/esm/types/wire.d.ts +6 -0
- package/dist/esm/types/wire.d.ts.map +1 -1
- package/dist/types/OndoProvider.d.ts.map +1 -1
- package/dist/types/auth/OndoClockDrift.d.ts +27 -0
- package/dist/types/auth/OndoClockDrift.d.ts.map +1 -0
- package/dist/types/auth/hmac.d.ts +1 -1
- package/dist/types/auth/hmac.d.ts.map +1 -1
- package/dist/types/auth/index.d.ts +1 -0
- package/dist/types/auth/index.d.ts.map +1 -1
- package/dist/types/auth/signActions.d.ts +6 -2
- package/dist/types/auth/signActions.d.ts.map +1 -1
- package/dist/types/types/wire.d.ts +6 -0
- package/dist/types/types/wire.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/OndoProvider.ts +17 -2
- package/src/auth/OndoClockDrift.ts +67 -0
- package/src/auth/hmac.ts +1 -1
- package/src/auth/index.ts +1 -0
- package/src/auth/signActions.ts +7 -4
- 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,
|
package/src/auth/signActions.ts
CHANGED
|
@@ -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
|
|
277
|
-
*
|
|
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
|
-
|
|
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
|
+
}
|