@sodax/skills 2.2.0-rc.7 → 2.2.0-rc.8
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/package.json +1 -1
- package/skills/sodax-dapp-kit/integration/knowledge/features/auxiliary-services.md +7 -5
- package/skills/sodax-sdk/integration/knowledge/features/sponsoring.md +3 -1
- package/skills/sodax-sdk/integration/knowledge/features/swaps-api.md +5 -0
- package/skills/sodax-sdk/integration/knowledge/recipes/initialize-sodax.md +1 -1
package/package.json
CHANGED
|
@@ -100,7 +100,9 @@ See the `sodax-sdk` skill (integration mode), `swaps-api.md` § `partnerFee`.
|
|
|
100
100
|
|
|
101
101
|
The backend guards `POST /swaps/*` with an API-key check. There is ONE instance-wide key: configure it
|
|
102
102
|
once on the provider config — `<SodaxProvider config={{ apiKey }}>` — and every `sodax.api.*` call these
|
|
103
|
-
hooks make carries it.
|
|
103
|
+
hooks make carries it. `SodaxProvider` runs in the browser, so a key passed there (or read from
|
|
104
|
+
`NEXT_PUBLIC_*` / `VITE_*`) is public. To keep it private, leave `apiKey` out, point `api.baseURL` and
|
|
105
|
+
`solver.solverApiEndpoint` at the app's own backend proxy, and attach the key there: https://docs.sodax.com/developers/how-to/api-key-good-practices. Override per request via the hooks' existing `apiConfig` param
|
|
104
106
|
(`RequestOverrideConfig`), which also accepts `apiKey`:
|
|
105
107
|
|
|
106
108
|
```ts
|
|
@@ -429,10 +431,10 @@ rather than on the HTTP status.
|
|
|
429
431
|
When the server rate-limits a key it also supplies `error.context.retryAfterSeconds`; render "try again
|
|
430
432
|
in Ns" instead of a generic "try later". The SDK never auto-retries a rate limit.
|
|
431
433
|
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
434
|
+
Sponsoring needs its own sponsoring-specific key, issued by the SODAX team — a partner portal key is
|
|
435
|
+
rejected there. Set it on `api.sponsoringApiConfig.apiKey`; it wins wherever the slice points. Without it,
|
|
436
|
+
the instance-wide key from `<SodaxProvider config={{ apiKey }}>` is sent to sponsoring whenever the call
|
|
437
|
+
targets a SODAX gateway root, and a portal key sent there fails. An api key
|
|
436
438
|
in a browser bundle is public by nature; the service's per-key quotas, fleet cap, per-IP throttle,
|
|
437
439
|
and origin gating are the real controls. Proxy through your own backend if that is not acceptable.
|
|
438
440
|
|
|
@@ -152,13 +152,15 @@ routes at its bare origin is reached with `baseURL: 'http://localhost:3011'`.
|
|
|
152
152
|
|
|
153
153
|
`apiKey` is folded into `x-api-key`. An api key in a browser bundle is public by nature: the service's
|
|
154
154
|
per-key quotas, fleet-wide daily cap, per-IP throttle, and origin gating are the real controls. Proxy
|
|
155
|
-
through your own backend if that is not acceptable.
|
|
155
|
+
through your own backend if that is not acceptable: https://docs.sodax.com/developers/how-to/api-key-good-practices.
|
|
156
156
|
|
|
157
157
|
The instance-wide `new Sodax({ apiKey })` is **gated** here, unlike every other backend service: it is
|
|
158
158
|
inherited only when the call targets a SODAX gateway (the packaged sponsoring default or the resolved
|
|
159
159
|
shared root), and the check runs per request against the effective target, so a per-call `baseURL`
|
|
160
160
|
override cannot carry it off-gateway. A custom sponsoring origin never receives it. The slice `apiKey`
|
|
161
161
|
above is the credential for independently hosted sponsoring and wins wherever the slice points.
|
|
162
|
+
Sponsoring keys come from their own registry (issued by the SODAX team, not the partner portal), so a
|
|
163
|
+
portal key that reaches sponsoring through inheritance is rejected — always set the slice `apiKey`.
|
|
162
164
|
|
|
163
165
|
## Cross-references
|
|
164
166
|
|
|
@@ -107,9 +107,14 @@ instance-wide key, `new Sodax({ apiKey })`, sent on every backend request — th
|
|
|
107
107
|
`RequestOverrideConfig`:
|
|
108
108
|
|
|
109
109
|
```ts
|
|
110
|
+
// Server-side only — a key in a browser bundle is public
|
|
110
111
|
await sodax.api.swaps.createIntent(body, { apiKey: 'per-request-key' });
|
|
111
112
|
```
|
|
112
113
|
|
|
114
|
+
The key belongs on a server. Never read it from `NEXT_PUBLIC_*` / `VITE_*` / `REACT_APP_*` — those are
|
|
115
|
+
inlined into the client bundle. When the SDK runs in a browser, point `api.baseURL` and
|
|
116
|
+
`solver.solverApiEndpoint` at the app's own backend proxy and attach the key there: https://docs.sodax.com/developers/how-to/api-key-good-practices.
|
|
117
|
+
|
|
113
118
|
Precedence, highest first: per-call `headers['x-api-key']` (any casing) → per-call `apiKey` → a
|
|
114
119
|
configured explicit `x-api-key` header (`api.headers` / `setHeaders`) → the configured `apiKey`. That
|
|
115
120
|
full order is what the data, swaps, and bridge transports resolve; sponsoring's tier 3 is its own
|
|
@@ -18,7 +18,7 @@ const result = sodax.config.isValidSpokeChainKey(ChainKeys.ARBITRUM_MAINNET);
|
|
|
18
18
|
import { Sodax, ChainKeys, type SodaxOptions } from '@sodax/sdk';
|
|
19
19
|
|
|
20
20
|
// `SodaxOptions` = `DeepPartial<SodaxDefaultConfig>` (the data override) plus the client-side options:
|
|
21
|
-
// `logger`, the global `fee`, the global `apiKey` (one instance-wide key, sent as `x-api-key` on every backend request; override per request via `RequestOverrideConfig.apiKey
|
|
21
|
+
// `logger`, the global `fee`, the global `apiKey` (one instance-wide key, sent as `x-api-key` on every backend request; override per request via `RequestOverrideConfig.apiKey`; server-side only — in a browser, proxy instead, see https://docs.sodax.com/developers/how-to/api-key-good-practices), and per-feature options on `swaps` / `bridge` (e.g. `{ useBackendSubmitTx: false }` — opt out of the default-on backend 2-step flow).
|
|
22
22
|
const config: SodaxOptions = {
|
|
23
23
|
// Per-chain overrides — merged with packaged defaults at the field level.
|
|
24
24
|
chains: {
|